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: 3 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 (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-10T19:10:07.000Z (about 5 years ago)
- Last Synced: 2024-08-09T01:39:31.013Z (3 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]
[![repo](https://img.shields.io/badge/repository-Github-black.svg?style=flat-square)](https://github.com/ryanburnette/scroll-to-by-speed)
[![npm](https://img.shields.io/badge/package-NPM-green.svg?style=flat-square)](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