Created
October 1, 2018 15:29
-
-
Save piersolenski/34a4c815f22fade2fad95acbd8fd7790 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
let starttime; | |
function moveit(timestamp, x, duration){ | |
const runtime = timestamp - starttime; | |
let progress = Math.min((runtime / duration), 1); | |
console.log(x * progress); | |
if (runtime < duration) requestAnimationFrame(timestamp => moveit(timestamp, x, duration)); | |
} | |
requestAnimationFrame(timestamp => { | |
starttime = timestamp; | |
moveit(timestamp, 400, 2000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment