Last active
March 12, 2021 05:56
-
-
Save bogoreh/2ee88142a557900dd3c92e930046395c to your computer and use it in GitHub Desktop.
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> | |
| <meta charset="utf-8"> | |
| <title>Challenge: Catwalk</title> | |
| <style> | |
| #cat { | |
| position: absolute; | |
| left: 0px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div> | |
| <!-- Cat walking GIF from: http://www.anniemation.com/clip_art/graphics.html --> | |
| <img id="cat" src="https://www.kasandbox.org/programming-images/misc/cat-walk.gif"> | |
| </div> | |
| <script> | |
| var catEl = document.getElementById("cat"); | |
| var startTime = new Date().getTime(); | |
| var walkTheCat = function() { | |
| var currTime = new Date().getTime(); | |
| var secondsElapsed = ((currTime - startTime)/ | |
| 1000); | |
| var newLeft = secondsElapsed * 67 + 1 + "px"; | |
| catEl.style.left = newLeft; | |
| window.requestAnimationFrame(walkTheCat); | |
| }; | |
| walkTheCat(); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment