Scroll events, debounced with `requestAnimationFrame`
npm install @substrate-system/raf-scrollScroll events, debounced with requestAnimationFrame.
Contents
- Install
- Example
- Modules
* Bundler
* Minified
sh
npm i -S @substrate-system/raf-scroll
`Example
`js
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.$3
Import like normal.
`js
import { rafScroll } from '@substrate-system/raf-scroll'
`$3
This package exposes minified JS too. Copy to a location that is
accessible to your web server, then link to it in HTML.
#### copy
`sh
cp ./node_modules/@substrate-system/raf-scroll/dist/index.min.js ./public/raf-scroll.min.js
`#### HTML
`html
``