I change the text color with requestAnimationFrame(animate);
function:
requestAnimationFrame(animate);
function animate(time){
... // change text color here
if (offset_s < offset_e) {requestAnimationFrame(animate);}
}
offset_s
and offset_s
indicates start and end positions of the text for color change. In some cases the animation should last for 2 seconds, but in order cases - for 5 seconds, but offset_e - offset_s
could be the same in these two cases. What can I do to control the speed of animation based on given time in seconds/milliseconds?