updwn
v1.0.0
Published
Tiny up/down scroll detection.
Downloads
44
Readme
updwn
Detect up/down directional scrolling. 500 bytes gzipped.
Install
npm i updwn --save
Usage
Handlers are only fired when the scroll direction changes and the scroll speed exceeds a configurable threshold value.
import updwn from 'updwn'
const scroll = updwn({ speed: 50 })
scroll.up(() => { /* up */ })
scroll.down(() => { /* down */ })
scroll.position // => 'up' or 'down'
Handlers can be destroyed by calling the function returned at the time of their definition.
const destroy = scroll.up(() => { /* up */ })
destroy()
License
MIT License © Eric Bailey