Hi, my problem is as follows:
I am building a site using GSAP to animate elements in ThreeJS.
ThreeJS renders 3d models in browser to a <canvas> element which is fixed to the viewport and placed behind DOM content.
When the page loads, I have it set for an element to tween from offscreen to a resting position on screen, then when I scroll, it will tween off the other side of the screen using a scrolltrigger with scrub enabled.
Initially, I was making a tween that fired when the page loaded, and then in the onComplete callback I was creating the scrolltrigger tween. The issue is that if I load halfway down the page, the first tween still fires and brings the element into the background.
gsap.from(this.wave.position, {
x: -20,
ease:'power4.inOut',
duration: 4,
onComplete: () => {
gsap.to(this.wave.position, {
x: 11,
y: "+= 1",
scrollTrigger: {
trigger: "#section-27-12",
start: "bottom 92%",
end: "bottom 55%",
scrub: 1
}
})
}
})
I guess the question I have is as follows:
If I want to have elements which tween into a hero section on load, but then are controlled by a scrollTrigger, how do I handle loading the page lower than said scrolltrigger?