开发者社区> 镜像站> NPM> debounce-raf
debounce-raf
Debounce function until next requestAnimationFrame. Auto cancel all extraneous calls between frames
Last updated 2 years ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install debounce-raf 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)