Created
March 14, 2016 21:45
-
-
Save StoneCypher/1f30dbe11bb836e9c6db to your computer and use it in GitHub Desktop.
animating a box allows you to see the problem visually, so that you can confirm it without a debugger
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> | |
| <style type="text/css"> | |
| #box { height: 100px; width: 100px; border: 1px solid blue; background-color: lightblue; } | |
| </style> | |
| <script type="text/javascript"> | |
| var i=0; | |
| var frame = function() { | |
| document.getElementById('label').innerHTML = (i++).toString(); | |
| document.getElementById('box').style.marginLeft = ((i % 400).toString() + 'px'); | |
| window.requestAnimationFrame(frame); | |
| }; | |
| window.requestAnimationFrame(frame); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="label"></div> | |
| <div id="box"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment