Hi everyone!
To create an infinite horizontal animation, I'm using horizontalLoop. However, it only runs on load, and I can't get it to work on component mount.
Where I get:
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
useIsomorphicLayoutEffect(() => {
let ctx;
// Animation initiation function
const initiateAnimation = () => {
ctx = gsap.context(() => {
const tl = horizontalLoop("img", {
repeat: -1,
paddingRight: 16,
});
}, content);
};
// Directly call on component mount
//initiateAnimation();
// Setup for window load
window.addEventListener("load", initiateAnimation);
// Cleanup
return () => {
ctx && ctx.revert();
window.removeEventListener("load", initiateAnimation);
};
}, []);
How can I initiate the animation upon component mounting?
This is important for when navigating away from the page and then returning.
Thanks