Skip to content

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

License

Notifications You must be signed in to change notification settings

ryanburnette/scroll-to-by-speed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published