Jump to content
Search Community

Scroll trigger - trigger all items with the same class issue

jjmolnar test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

  • Solution
18 minutes ago, jjmolnar said:

I thought that scrollTrigger only takes the element in the viewport and animate that exact one.


Hey @jjmolnar


ScrollTrigger is incredibly powerful, but it can't know what you want if you don't explicitely tell it to. The way you have things set up, you are adressing all elements with the class .title with your tween and triggering the animation for all of them on the first element with that class. If you want to trigger an animation for each element individually, it would probably be best to loop over all the items and create a ScrollTrigger forEach of them individually.


See the Pen 4e1dea41abea031de7b9adaed8170647 by akapowl (@akapowl) on CodePen



This is actually one of the most common ScrollTrigger mistakes (and probably GSAP mistakes in general); using generalselectors when wanting to animate specific elements only. You can read on that in this article, which is very helpful in a lot of cases, when things don't work as you might expect.





In a case like this when using scrub, you would also have to make sure that there is enough scrollable content at the end, if you wanted to make sure that your last scrubbing-tween can finish its scrubbing animation.


Hope this helps.

Cheers, Paul.


  • Like 3
Link to comment
Share on other sites

  • 1 year later...

To trigger a click on multiple elements with the same class but when i do so the first element only get clicked and not the others, frankly I'm trying to make likes on customwritings com review to ask from profile answers by using the console of firefox so this is what i did $('.like').trigger('click'); I don't think this is that easy to use one handler for all the Triggers on multiple Objects as you need to refer the Objects and some of them doesn't have any relationship between them.

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...