NickNo Posted April 21, 2022 Share Posted April 21, 2022 Hi, I'm trying to create a combined animation with scrub, with adding a class via toggleClass - at the moment the class only gets applied until the animation/trigger end - how would I keep the class applied until I reverse back up to the top? See the Pen yLpwbOX by nickjacobsnz (@nickjacobsnz) on CodePen Link to comment Share on other sites More sharing options...
akapowl Posted April 22, 2022 Share Posted April 22, 2022 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 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now