Skip to content

Instantly share code, notes, and snippets.

@koozdra
Last active March 13, 2016 21:07
Show Gist options
  • Save koozdra/fd1248798af4893b2deb to your computer and use it in GitHub Desktop.
Save koozdra/fd1248798af4893b2deb to your computer and use it in GitHub Desktop.
Animation loop
// don't have to declare frame, purer
function animate(fn) {
function anim(frame) {
fn(frame);
requestAnimationFrame(_.partial(anim, frame + 1));
}
requestAnimationFrame(_.partial(anim, 0));
}
function animate(fn) {
var frame = 0;
requestAnimationFrame(function runner() {
fn(frame);
frame += 1;
requestAnimationFrame(runner);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment