1.0.1 • Published 5 years ago
debounce-raf v1.0.1
debounce-raf
Debounce function until next requestAnimationFrame. Auto cancel all extraneous calls between frames
Usage
const raf = require('debounce-raf')
const render = raf(function ({ time }) {
document.body.textContent = `Update on ${time}`
})
// Called every 4ms, but will only render efter animation frame, with the latest
// call
setInterval(render, 4, { time: Date.now() })
API
var debouncedFn = raf(fn)
Debounce fn
to every animation frame. Cancel all calls in between. Will
forward any args passed to debouncedFn
onto fn
.
Install
npm install debounce-raf