Сообщение от Uthvfy62
|
или же как сделать скрипт устойчивым.
|
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div id="block"></div>
<script>
let prev = performance.now();
let delay = 1500;
let max = 7;
let block = document.getElementById('block');
let temp;
requestAnimationFrame(function measure(time) {
let i = Math.ceil((time - prev) / delay % max);
if (i && temp !== i) {
block.insertAdjacentHTML("beforeEnd", `<b>${i}</b> `);//для проверки
block.className = `active${i} block`;
temp = i;
}
requestAnimationFrame(measure);
})
</script>
</body>
</html>