updwn

Tiny up/down scroll detection.

  • updwn

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
updwn
911.0.05 years ago6 years agoMinified + gzip package size for updwn in KB

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