Skip to content

Instantly share code, notes, and snippets.

@mateuszkocz
Created August 16, 2013 18:08
Show Gist options
  • Save mateuszkocz/6252131 to your computer and use it in GitHub Desktop.
Save mateuszkocz/6252131 to your computer and use it in GitHub Desktop.
var start = null;
var d = document.getElementById("SomeElementYouWantToAnimate");
function step(timestamp) {
var progress;
if (start === null) start = timestamp;
progress = timestamp - start;
d.style.left = Math.min(progress/10, 200) + "px";
if (progress < 2000) {
requestAnimationFrame(step);
}
}
requestAnimationFrame(step);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment