JSFiddle - React, Tailwind, and code Playground
by Alex Alex
HTML
<div></div>
CSS
div {
background:red;
width: 10px;
height: 10px;
position:absolute;
left: 0;
top: 10px;
}
JavaScript
var div = document.querySelector('div');
var progress = 0;
function step() {
var left = parseInt(div.style.left || 0, 10) + 10 + "px";
div.style.left = left;
if (progress < 200) {
progress++;
requestAnimationFrame(step);
}
}
requestAnimationFrame(step, div);