1 | # raf
|
2 |
|
3 | [![browser support](http://ci.testling.com/chrisdickinson/raf.png)](http://ci.testling.com/chrisdickinson/raf)
|
4 |
|
5 | reqeustAnimationFrame polyfill for browserify.
|
6 |
|
7 | ```javascript
|
8 | var raf = require('raf')
|
9 | , canvas = document.getElementById('opengl')
|
10 |
|
11 | raf(canvas)
|
12 | .on('data', function(dt) {
|
13 | console.log('difference in time is '+dt+'ms')
|
14 | })
|
15 |
|
16 |
|
17 | ```
|
18 |
|
19 | # API
|
20 |
|
21 | ## raf([optional element], [optional tick function]) -> event emitter
|
22 |
|
23 | returns a event emitter that immediately starts emitting 'data'
|
24 | events representing animation frames for a given element (or for the entire
|
25 | window, if no element is passed).
|
26 |
|
27 | if you pass a function as the first or second argument it will get called on every tick. this is a convenience method for
|
28 | the example above that binds to the `data` event, e.g. `raf().on('data', tickFunction)` is the same as `raf(tickFunction)`
|
29 | or `raf(el, tickFunction)`
|
30 |
|
31 | ## ee.pause() / ee.resume()
|
32 |
|
33 | pauses or resumes the events coming out of `ee`.
|
34 |
|
35 | the `dt` on the next event after a resume will represent the difference between
|
36 | the last rendered frame and the newest frame.
|
37 |
|
38 | ## raf.polyfill
|
39 |
|
40 | the polyfilled `requestAnimationFrame` function.
|
41 |
|
42 | # license
|
43 |
|
44 | MIT
|
45 |
|