raf-listen

Call a function at most once per animation frame

Usage no npm install needed!

<script type="module">
  import rafListen from 'https://cdn.skypack.dev/raf-listen';
</script>

README

raf listen

js-standard-style

Call a function at most once per animation frame.

Featuring:

  • commonjs
  • no es6

install

$ npm install raf-listen

example

var throttle = require('raf-listen')
// polyfill raf if you want
require('raf').polyfill()

setInterval(function () {
  console.log('unthrottled')
}, 5)

setInterval(throttle(function () {
  console.log('throttled')
}), 5)