CodeBoi Posted October 16, 2020 Share Posted October 16, 2020 i managed to toggle class when scrolling but when i am scrolling back up i wish to activate a different class gsap.timeline({ scrollTrigger: { trigger: "#tesla-car", start: "center center", end: "+=900", toggleClass: "active" }, }); here is the code im currently using ^ but i want to toggle a different class when i scroll back up (hopefully thats understandable Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 16, 2020 Share Posted October 16, 2020 Hey CodeBoi. You should use ScrollTrigger's callback methods (like onEnter, onLeave, onEnterBack, and onLeaveBack) to do more custom logic like this. With that being said it might make more sense to just do what you need to do with an animation attached to your element(s) instead of toggling classes. Without seeing a minimal demo it's hard for us to give finite advice Link to comment Share on other sites More sharing options...
CodeBoi Posted October 16, 2020 Author Share Posted October 16, 2020 3 hours ago, ZachSaucier said: Hey CodeBoi. You should use ScrollTrigger's callback methods (like onEnter, onLeave, onEnterBack, and onLeaveBack) to do more custom logic like this. With that being said it might make more sense to just do what you need to do with an animation attached to your element(s) instead of toggling classes. Without seeing a minimal demo it's hard for us to give finite advice wont lie had trouble yesterday adding tween but i finally managed to do it (for those wondering why i used animations instead of gsap in the first place was due to an issue of the svg rotating out of place i fixed that by adding " transformOrigin: 50% 50% " to the gsap animation) now im using tween 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