Jump to content
Search Community

ScrollTrigger toggleClass and animation

NickNo test
Moderator Tag

Recommended Posts

Hello there, Nick.

 

As you already found out, toggleClass will toggle a class every time the ScrollTrigger changes its state from active to inactive and vice versa, i.e. on each of enter/leave/enterBack/leaveBack.

 

So if you only wanted to toggle a class on certain events, you'd have to use the callback system - e.g. add the class to the element onEnter and remove it again onLeaveBack. Something like this:

 

See the Pen jOYREob by akapowl (@akapowl) on CodePen

 

  • Like 3
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...