JSFiddle - React, Tailwind, and code Playground
by thetenfold
HTML
<div id="mydiv" style="position: relative; left: 0px;">hello world</div>
JavaScript
(function() {
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
window.requestAnimationFrame = requestAnimationFrame;
})();
var start = null;
var d = document.getElementById("mydiv");
function step(timestamp) {
var progress;
if (start === null) start = timestamp;
progress = timestamp - start;
d.style.left = Math.floor(progress / 10) + "px";
if (progress < 6000) {
requestAnimationFrame(step);
}
}
requestAnimationFrame(step);