Skip to content

Instantly share code, notes, and snippets.

@jeremyckahn
Created April 5, 2012 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeremyckahn/2307877 to your computer and use it in GitHub Desktop.
Save jeremyckahn/2307877 to your computer and use it in GitHub Desktop.
An example of requestAnimationFrame (webkit version)
<!doctype html>
<html>
<head></head>
<body>
<div id="my-el" style="background: red; height: 40px; width: 40px;"></div>
<script>
var el = document.getElementById('my-el');
el.style.position = 'absolute';
var left = 0;
function update () {
el.style.left = left + 'px';
left++;
webkitRequestAnimationFrame(update);
}
update();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment