https://codepen.io/aswinckr/pen/RJvKjq
This is a two part question -
I'm trying to build a continuous infinite loop animation with plain javascript with setInterval and setTimeout methods with applying css properties. When i switch browser tabs and return to this after a while my animations seem to behave very unexpectedly. Why does this happen??
After reading online I understand that requestAnimationFrame is recommended way to do animations using javascript. In my case i'm using JS to trigger transform and scale properties in css with a transition property. Even if i were to use requestAnimationFrame with a ease or bezier function lets say, how would I take care of the setTimeout functionality? Where after animating between first and second cards to repeat the animation from second to third..
The link to codepen is pasted above. Thanks in advance!