Scroll events, debounced with requestAnimationFrame
.
npm i -S @substrate-system/raf-scroll
import { rafScroll } from '@substrate-system/raf-scroll'
rafScroll(ev => {
// this is called at most once per animation frame
console.log('scroll event', ev)
})
This exposes ESM and common JS via package.json exports
field.
Import like normal.
import { rafScroll } from '@substrate-system/raf-scroll'
This package exposes minified JS too. Copy to a location that is accessible to your web server, then link to it in HTML.
cp ./node_modules/@substrate-system/raf-scroll/dist/index.min.js ./public/raf-scroll.min.js
<script type="module" src="./raf-scroll.min.js"></script>