код из ссылки выше, что не так?
<div class="num"></div>
<script>
const elem = document.querySelector('.num');
const anim = () => {
let d = performance.now(),
from = 1,
to = 2.1,
duration = 5000;
requestAnimationFrame( function e(b) {
b = (b - d) / duration;
1 <= b && (b = 1);
let c = from + (to - from) * b ;
elem.innerHTML = c.toFixed(3);
b == 1 && alert('end');
1 > b && requestAnimationFrame(e)
})
}
anim()
</script>
|