Created
April 5, 2012 04:10
-
-
Save jeremyckahn/2307877 to your computer and use it in GitHub Desktop.
An example of requestAnimationFrame (webkit version)
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
<!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