XXVII Posted August 25, 2022 Share Posted August 25, 2022 Hello, I'm trying to start the trigger 100px before the top of element reaches the center of the viewport and stop the trigger 100px after the bottom of the element reaches the center of the viewport. I succeded at starting 100px before, but I can't figure out how to end 100px after, this is the first thing I tried: scrollTrigger: { start: '-100px center', end: '+100px center', trigger: element, toggleClass: 'class' } Other attempts: "bottom +100px center" "100% +100px center" "+=100px center" Any suggestion? Thank you Link to comment Share on other sites More sharing options...
Solution mvaneijgen Posted August 25, 2022 Solution Share Posted August 25, 2022 Hi @XXVII welcome to the forum! Be sure to include a minimal demo next time, so that we can see the code not working in action. start: 'top-=100px center', end: 'bottom+=100px center', You almost had it. You want it to be relative to the bottom of the element so you can use `-=` or `+=`, so the end: trigger would be `end: 'bottom+=100px center'` and GSAP is smart, but even though `-100px` works I would suggest writing it out like so `start: 'top-=100px center'`, this way your code will be easier to read. 1 Link to comment Share on other sites More sharing options...
XXVII Posted August 25, 2022 Author Share Posted August 25, 2022 Oh, wow, thank you! I was an equal sign from the solution! 😅 PS: I didn't include a demo because I guessed the problem was very banal, but I will consider it next time. 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