Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/scroll-speed
Get the scroll speed being used on either the window or a particular element.
https://github.com/hughsk/scroll-speed
Last synced: 23 days ago
JSON representation
Get the scroll speed being used on either the window or a particular element.
- Host: GitHub
- URL: https://github.com/hughsk/scroll-speed
- Owner: hughsk
- License: other
- Created: 2014-05-12T12:50:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-22T20:23:17.000Z (about 6 years ago)
- Last Synced: 2024-10-01T15:26:31.649Z (about 1 month ago)
- Language: JavaScript
- Size: 136 KB
- Stars: 22
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# scroll-speed [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
Get the scroll speed being used on either the window or a particular element.
## Usage
[![NPM](https://nodei.co/npm/scroll-speed.png)](https://nodei.co/npm/scroll-speed/)
### speed = scroll(element, [preventDefault])
Listens to `element` for scroll events. If you don't supply an element, this
will default to `window`. Pass `preventDefault` as `true` to override the
default scrolling behavior.### speed.on('scroll', callback(event))
Calls `callback` whenever a scroll event is captured, passing a normalized
`wheel` event for you to read from.### speed.flush()
You need to call at the end of each frame for the module to work properly – we
need to cater to the possibility of multiple events per frame. Stick this at
the end of your `requestAnimationFrame` or `setInterval` loop.### speed[0]
The horizontal speed of the scroll.
### speed[1]
The vertical speed of the scroll.
### speed[2]
The depth speed of the scroll – you never know!
## License
MIT. See [LICENSE.md](http://github.com/hughsk/scroll-speed/blob/master/LICENSE.md) for details.