@substrate-system/raf-scroll
v0.0.4
Published
Scroll events, debounced with `requestAnimationFrame`
Downloads
140
Maintainers
Readme
raf scroll
Scroll events, debounced with requestAnimationFrame.
Install
npm i -S @substrate-system/raf-scrollExample
import { rafScroll } from '@substrate-system/raf-scroll'
rafScroll((ev:number) => {
// this is called at most once per animation frame
// `ev` is just the Y scroll position (window.scrollY)
console.log('scroll Y', ev)
})Modules
This exposes ESM and common JS via package.json exports field.
Bundler
Import like normal.
import { rafScroll } from '@substrate-system/raf-scroll'Minified
This package exposes minified JS too. Copy to a location that is accessible to your web server, then link to it in HTML.
copy
cp ./node_modules/@substrate-system/raf-scroll/dist/index.min.js ./public/raf-scroll.min.jsHTML
<script type="module" src="./raf-scroll.min.js"></script>