Good night friends, I'm new to GSAP but have been experimenting with it a little bit and found myself against an intangible wall.
What am I trying to do?
Expected behaviour: You are scrolling down, at a certain moment a scrub starts and at the bottom of the viewport a wave starts to come up. The wave settles there at the bottom, and you can see it moving up and down (like the sea would). If you keep scrolling down, the wave should scrub down again and disappear.
If you scroll up the wave scrubs up again, moves up and down, if you keep scrolling up it scrubs down.
I've been trying to do this and I got some progress but I feel like I am not doing it the correct way. For the up and down, sea style animation, I used a gsap.to() with repeat, and with the triggerActions I got it to work only when on viewport.
And for the first and second scrub I used gsap.fromTo(), and it worked, sort of. But... when I would scroll fast the animation would break. And that led me to realize that I am not doing this thing the right way. I may be just typing unnecesary code cause I don't know the precise mechanisms I need.
How would you approach something similar? The animations are (afaik):
- scrub (image arises from the bottom)
- sea like animation
- scrub (image sinks to the bottom)
This should work scrolling down and scrolling up again
(THE CODEPEN ONLY HAS THE 2 SCRUBS, IN THE CODEPEN THEY WORK FINE BECAUSE IT ISNT AN IMAGE, AND THE SCROLL IS TOO SHORT, BUT ON A NORMAL HEIGHT SCREEN IT GLITCHES. IS THIS THE MOST PERFORMANT WAY TO DO WHAT I AM TRYING TO DO?)