scroll-to-by-speed

2.0.0 • Public • Published

scroll-to-by-speed

repo npm

Animated scrolling should be a function of speed, not time.

There are lots of ways to scroll that accept a duration argument. This library doesn't handle scrolling for you, but it will calculate the duration based on speed given an element, a direction, and a context.

You might be thinking that you don't need a library for this. That's good. This library exists to promote the concept.

Usage

function scroll(element, duration) {
  // your favorite scrolling technique goes here
}
var speed = 1000; // pixels per second
var element = document.querySelector('div');
var duration = scrollToBySpeed({ speed, element });
scroll(element, duration);

Readme

Keywords

none

Package Sidebar

Install

npm i scroll-to-by-speed

Weekly Downloads

5

Version

2.0.0

License

ISC

Unpacked Size

2.89 kB

Total Files

4

Last publish

Collaborators

  • ryanburnette