JSFiddle - React, Tailwind, and code Playground
by Owen Hartley
HTML
<div id="test"></div>
<p id="test2"></p>
CSS
#test {
width: 32px;
height: 32px;
background-color: black;
display: block;
position: absolute;
left: 0;
top: 0px;
}
JavaScript
var div = document.getElementById("test");
var div2 = document.getElementById("test2");
var x = 0;
var x2 = 0;
var speed = 1;
function moving() {
}
function test() {
x++;
x2 = Math.floor(x / 60) * 60;
div2.innerHTML = x;
div.style.left = x2 + "px";
window.requestAnimationFrame(test);
}
window.requestAnimationFrame(test);