All Projects → hughsk → Scroll Speed

hughsk / Scroll Speed

Licence: other
Get the scroll speed being used on either the window or a particular element.

Programming Languages

javascript
184084 projects - #8 most used programming language

scroll-speed experimental

Get the scroll speed being used on either the window or a particular element.

Usage

NPM

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 for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].