Jump to content
Search Community

Repeatable in viewport animations with scrollTrigger

panoonan test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hello, all. I am working on a site where there are various elements that I want to have a repeatable behavior on their entering of the viewport. For example, each section has text that needs to turn red once it is visible in the viewport as you scroll. I have used the basic example from the docs and it works as expected with the triggering event causing the text to change. The issue is that the trigger seems to then affect EVERY instance. So instead of scrolling and seeing the text change, after the first triggering, all of ".go-red" elements have completed their tween.

 

gsap.to(".go-red", 1.5, {
  scrollTrigger: ".go-red",
  color: "red"
});

 

I am sure there is a simple way to do this that doesn't involve id based triggering but it is stumping me. Any help is appreciated.

See the Pen MWvwBPQ by panoonan (@panoonan) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...