npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

magical-scroll

v1.0.15

Published

## Basic Usage

Downloads

280

Readme

Magical Scroll

Basic Usage

MagicalScroll.getInstance().addElement({
  target: "#scroll",
  animations: {
    opacity: {
      positions: [0, 100],
      values: [0, 1],
    },
  },
});

Magic Slugs

| Slug | Description | | - | - | | #screenWidth | width of the screen | | #screenHeight | height of the screen | | #scrollWidth | width of the scroll container | | #scrollHeight | height of the scroll container | | #elementWidth | width of the element | | #elementHeight | height of the element | | #elementIn | when the element appear at the bottom of the container | | #elementOut | when the element disappear at the top of the container | | #elementCenter | when the element is placed center of the container | | #parentElementWidth | width of the parent element (node) | | #parentElementHeight | height of the parent element (node) | | #parentElementIn | when the parent element (node) appear at the bottom of the container | | #parentElementOut | when the parent element (node) disappear at the top of the container | | #parentElementCenter | when the parent element (node) is placed center of the container | | #ancestorElementWidth{1} | width of the ancestor element (node), where {1} means the generation(s) | | #ancestorElementHeight{1} | height of the ancestor element (node), where {1} means the generation(s) | | #ancestorElementIn{1} | when the ancestor element (node) appear at the bottom of the container, where {1} means the generation(s) | | #ancestorElementOut{1} | when the ancestor element (node) disappear at the top of the container, where {1} means the generation(s) | | #ancestorElementCenter{1} | when the ancestor element (node) is placed center of the container, where {1} means the generation(s) |

Built-in Properties

| Name | Description | | - | - | | opacity || | scale || | rotate || | translateX || | translateY || | display | none or just nothing | | visibility | visible or hidden | | backgroundColor | calculating within values | | color | calculating within values |

Register/Replace your own property

Register/Replace the value populating callback

const magicalScroll = MagicalScroll.getInstance();
const animationName = "myScrollAnimation";
magicalScroll.registerPropertyPopulateCallback(
  animationName,
  (currentPosition, positions, values) => {
    const index = positions.findIndex((position) => position > currentPosition);
    return index > -1 ? values[index] : values[values.length - 1];
  },
);

Explanation

| Name | Meaning | | - | - | | currentPosition | current scroll top of the container | | positions | list of position which are already computed as a number | | values | list of value |

You can also register a new animation with existed built-in callback

const magicalScroll = MagicalScroll.getInstance();
const animationName = "opacity";
magicalScroll.registerPropertyPopulateCallback(
  animationName,
  MagicalScroll.populateNumberValueCallback,
);

Register/Replace the CSS generation callback

const magicalScroll = MagicalScroll.getInstance();
const animationName = "myScrollAnimation";
magicalScroll.registerPropertyPopulateCallback(
  animationName,
  (target, property, value) => {
    target.style.display = value ? null : "none";
  }
);

Explanation

| Name | Meaning | | - | - | | target | element target | | property | name of the property, animationName as the example above | | value | computed value |

What the next?

  1. Provide other properties something like skew, brightness.
  2. Interaction Observer API for better performance.
  3. Support multiple instances.
  4. Child slug.
  5. Query for element.
  6. Function of toggling class by position.
  7. Inertia?
  8. Animation function (ease-in-out, ... etc.) support.
  9. Refactor it into better architecture.
  10. Matrix calculation.