Hi there @liamny
Welcome to the GSAP forums! ?
FYI - I made a little tweak to the CSS in your pen so I could scroll on my device. Setting the container to 200vh instead of a pixel value.
You weren't far off a solution!
I couldn't recreate the issue you were having with the button but the syntax you currently have can be simplified a little, maybe this will help?
gsap.timeline({
scrollTrigger: {
trigger: ".button",
end: 'bottom',
toggleClass: "blockDiv",
}
});
For the tip - the magic is all in toggleactions - This determines how the animation is controlled as it toggles in and out of view.
You're looking for toggleActions: "play reset none reset"
This will play when it enters the viewport - reset when it leaves, take no action when scrolled back into view, and reset when it leaves again (scrolled all the way back).
Here's an adjusted codepen. Hope this helps! https://codepen.io/cassie-codes/pen/25cc28b1d8952dd12f460a7fd63cf807?editors=0010