Skip to content
Tiny up/down scroll detection.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
README.md
index.js
package-lock.json
package.json

README.md

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

You can’t perform that action at this time.