How do I rewrite this animation with - requestAnimationFrame?
-
Made a little animation with setInterval
How can you do it using requestAnimationFrame? Tried different options, but either gives an error or the animation doesn't start
Code - sandboxJavaScript Cora Hutchinson, Mar 5, 2020 -
const popupAnimate = () => {
let startAnimate = performance.now();
const loop = (now) => {
let timePassed = now - startAnimate;
popupContent.style.top = timePassed / 7 + "px";
if (timePassed > 3000) return;
requestAnimationFrame(loop);
};
requestAnimationFrame(loop);
};Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!