Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://ryanburnette.github.io/scrollToBySpeed
Animated scrolling should be a function of speed, not time.
https://ryanburnette.github.io/scrollToBySpeed
Last synced: 2 months ago
JSON representation
Animated scrolling should be a function of speed, not time.
- Host: GitHub
- URL: https://ryanburnette.github.io/scrollToBySpeed
- Owner: ryanburnette
- License: isc
- Created: 2014-04-01T13:48:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-10-10T19:10:07.000Z (over 5 years ago)
- Last Synced: 2024-12-09T22:36:14.309Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 216
- Watchers: 9
- Forks: 20
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [scroll-to-by-speed][1]
[](https://github.com/ryanburnette/scroll-to-by-speed)
[](https://www.npmjs.com/package/scroll-to-by-speed)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
```js
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);
```[1]: https://github.com/ryanburnette/scroll-to-by-speed