Hi Jack,
Again massive thanks. That does help a lot. 90% of it makes sense, and the remaining 10% shows that I've still got some learning to do!
I've almost got it working perfectly now... in your codepen above it works beautifully until you scroll down and back up again.
At that point the ScrollTrigger does exactly what it should pauses, restarts and plays the timeline again, but the Wander function keeps running as it isn't part of the timeline.
I want the onComplete to respect the ScrollTrigger rules - i.e. play pause restart pause
I've tried for example:
scrollTrigger: {
trigger: ".container",
markers: true,
start: "top 75%",
end: "bottom 25%",
toggleActions: "play pause restart pause",
onLeave: () => wander.pause()
},
onComplete: () => wander(animationContainer.querySelector(".circle"))
The idea was to pause Wander within ScrollTrigger, but no joys.
I've been looking at eventCallback, i.e. "onComplete", "onUpdate", "onStart", "onReverseComplete" but there's no 'on leave' style option here to pause that animation.
I also looked at wander.kill but again I don't have an option for 'on leave' to use it.
Is there a way to make wander be part of the t1 timeline so it can respect the toggle actions?