animate
Version:
A small wrapper around requestAnimationFrame that adds a frame rate constraint.
28 lines (20 loc) • 862 B
Markdown
animate is a small wrapper around requestAnimationFrame that adds a frame rate constraint. It also provides simple `pause` and `resume` methods. The code is based on [this blog article](http://codetheory.in/controlling-the-frame-rate-with-requestanimationframe/).
[](https://ci.testling.com/michaelrhodes/animate)
<small>Older browsers might require a polyfill for [Function.prototype.bind](http://kangax.github.io/es5-compat-table/#Function.prototype.bind).</small>
```sh
$ npm install animate
```
``` js
var animate = require('animate')
// Run the frame 24 times a second.
var animation = animate(function frame() {
// Blah, blah, some animation.
}, 24)
animation.pause()
animation.resume()
```
[](http://opensource.org/licenses/MIT)