JSFiddle - React, Tailwind, and code Playground
by andrelaszlo
HTML
<div id="SomeElementYouWantToAnimate"></div>
CSS
#SomeElementYouWantToAnimate {
width: 100px;
height: 100px;
background-color: #226699;
position: absolute;
}
JavaScript
var start = null;
var element = document.getElementById("SomeElementYouWantToAnimate");
function step(timestamp) {
if (!start) start = timestamp;
var progress = timestamp - start;
element.style.left = Math.min(progress/10, 200) + "px";
window.requestAnimationFrame(step);
}
window.requestAnimationFrame(step);