animateBanner() {
let counter = 0;
const intervalTime = 3000;
const tlm = new TimelineMax({ paused: true });
setInterval(() => {
if (counter === this.bannerPhotos.length) {
tlm.to(this.banner.nativeElement, 0, {
x: '-100vw'
});
counter = 0;
}
tlm.to(this.banner.nativeElement, 1, {
x: '-=100vw',
ease: Sine.easeOut
});
tlm.play();
counter++;
}, intervalTime);
}
I am creating an infinite loop carousel with GSAP, I'm having issues with setInterval where the animation goes really fast when I switch to other tabs then I go back. How can I refactor the code above using the GSAP way.