debounce-raf

1.0.1 • Public • Published

debounce-raf

Build Status

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

License

ISC

Readme

Keywords

none

Package Sidebar

Install

npm i debounce-raf

Weekly Downloads

20

Version

1.0.1

License

ISC

Unpacked Size

5.16 kB

Total Files

7

Last publish

Collaborators

  • emilbayes