🐭 A tiny 250b scroll listener with progress.
Clone or download
Latest commit 511acf5 Jan 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo Update demo with instance removal. Jan 15, 2019
src fix: convert to spaces Jan 11, 2019
.gitignore Initial commit! Jan 10, 2019
LICENSE Initial commit! Jan 10, 2019
README.md Initial commit! Jan 10, 2019
package.json 1.1.1 Jan 15, 2019

README.md

Update On Scroll (uos)

npm version gzip size license dependencies

Update On Scroll (uos) is a 250b library to provide the easiest way for updating values on scroll. Based on percentual or pixel based begin and end values, progress is returned trough a callback.

This utility can be useful for CSS animations, DOM changes, WebGL transitions or anything that can be updated based on a progress value.

Features:

  • Small in size, no dependencies
  • Percentage or pixel based values
  • Optimized for multiple instances

Install

$ npm install --save uos

Usage

Import the library:

import updateOnScroll from 'uos';

Update an element based on pixels:

updateOnScroll(100, 500, progress => {
  // Progress between 100px and 500px
});

Update an element based on percentages:

updateOnScroll(0.2, 0.6, progress => {
  // Progress between 20% and 60%
});

Only a single scroll listener will be used regardless of how many instances are created. The callback of an instance will be called on every update.

License

MIT © Colin van Eenige