amitr95 Posted January 17, 2023 Share Posted January 17, 2023 I'm trying to add a class on scroll to make the header fixed. However, the class isn't being applied? I've seen existing posts on this, all which go about the same / similar way I have applied the snippet in my demo, but it doesn't work in my use case? https://ihatetomatoes.net/scrolltrigger-tutorial-toggleactions-toggleclass/ See the Pen bGjRjzp by amit_rai95 (@amit_rai95) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted January 18, 2023 Share Posted January 18, 2023 That's because of this: end: "+=1" That means it toggled the class but if you scrolled more than 1 pixel past the start, it toggled it back again. Your entire ScrollTrigger only lasts 1 pixel. I assume you meant something more like this?: See the Pen jOpGvJL by GreenSock (@GreenSock) on CodePen But even that seems odd to me; why are you even toggling that class at all if it's gonna be on the entire time (start: 0, end: 99999)? Why not just apply that class directly and leave it there (no ScrollTrigger involvement)? 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