raf-core
Request Animation Frame as a beating heart.
Idea
Using requestAnimationFrame in a similar way as setTimeout is counterintuitive and cumbersome. This package introduces a new way of performing certain actions on every repaint by wiring up an EventEmitter as a single source of truth for window repaints.
Installation
- Node.js, browserify
npm install raf-core --save
(yes, it even works on servers) - Require.js
require(["raf-core"], ...
Example
var rafCore = ; // Executes a function on every window repaintrafCore;
Since rafCore is an instance of Node's EventEmitter, you can exploit all its features.
var rafCore = ; var { console;}; rafCore; // Removes the onBeat event listener after 5 seconds;