If you have a look at https://www.foundationstacks.com, there is a "Loved by Users" section that scrolls horizontally using GSAP. If you hover over it, it will pause. You can then also manually scroll horizontally at your leisure. When you mouse-out, I would like to restart the animation at the current position. How can I set the timeline to restart at a defined position, instead of seek to a point in the timeline before I resume the animation?
const tl = gsap.timeline({
repeat: -1,
repeatDelay: this.options.delay,
paused: true,
scrollTrigger: {
trigger: this.container,
onEnter: () => tl.play(),
onEnterBack: () => tl.resume(),
onLeave: () => tl.pause(),
onLeaveBack: () => tl.pause(),
}
});
const easing = this.gsapEasingFunction(this.options.easeFunc,this.options.easeCurve);
tl.to(this.container, {duration: this.options.timing, scrollTo:{y:0, x:"max"}, ease:easing});
tl.to(this.container, {duration: this.options.timingBack, delay: this.options.delay, scrollTo:{y:0, x:0}, ease:easing});
// hover pause
this.container.addEventListener("touchstart", () => tl.pause());
this.container.addEventListener("mouseenter", () => tl.pause());
this.container.addEventListener("mouseleave", () => tl.resume());