Last active
March 13, 2016 21:07
-
-
Save koozdra/fd1248798af4893b2deb to your computer and use it in GitHub Desktop.
Animation loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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