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

parallaxative

v0.5.2

Published

Utilities to run code based on the viewport position of an HTML element

Downloads

20

Readme

Parallaxative

A vanilla JS library to help those who must implement parallax under duress. Contains several classes to help run code based on the viewport position of an HTML element.

This seems to work decently in most circumstances, but the API is in the process of being cleaned up substantially, and it needs massive documentation improvements. Use at your own risk.

Special thanks to Barry T. Smith for the excellent name

Usage

/src/parallaxative.js is an ES7 module; /dist/parallaxative.min.js is an ES5 script you can shove into a <script> tag. They both offer utility classes with no default side effects.

The classes are kind of documented in the module file; friendlier documentation here is on my TODO list.

/demo/demo.js has very basic examples of how to use ScrollAnimation and ParallaxAnimation.

See the issue queue to get an idea of the improvements I want to make.

Development and demo

~~npm install, as always. Then npm run build to compile changes, or npm run demo to launch the demo page.~~

Bundling and demo preview are now handled by CodeKit (version 3.8 or higher). Webpack and all other JavaScript-based build tools are abominations whose primary benefit is providing security vulnerabilities for GitHub to detect and pester you about.

Included classes

ScrollDetector

Give its constructor an HTMLElement, and its methods will give you a float representing its relative progress across your screen:

  • 0 means it's one pixel away from scrolling onto the bottom of the screen
  • 1 means it's just barely scrolled off the top of the screen
  • All other values are interpolated linearly

A constructor option allows you to track horizontal instead of vertical scrolling, and all the classes below work (or can easily be made to work) with horizontal scrolling as well.

ScrollTrigger

Give its constructor a ScrollDetector, a function, and a float, and it will run the function when the ScrollDetector is greater than or equal to the float.

This class is most unfinished one in the library.

ScrollAnimationValueSet

This class manages the CSS values for a ScrollAnimation; it doesn't do much beyond merging supplied options with default options. I need to think about whether this class should even exist, or just be rolled into ScrollAnimation itself.

ScrollAnimation

Changes an element's style attribute on scroll (throttled by requestAnimationFrame) based on the output of a ScrollDetector and the CSS rules you describe in one or more ScrollAnimationValueSets.

ParallaxAnimationValueSet

Manages the CSS values for a ParallaxAnimation.

ParallaxAnimation

A subclass of ScrollAnimation for the special case of a background element that needs to scroll at a precise factor of the speed at which the page is being scrolled. Handles proper sizing of the background element.