Jump to content


ScrollTrigger conditional toggleClass

Go to solution Solved by GreenSock,

Recommended Posts

I am toggling class at box-container (black borderbox on left) based on selector's (color boxes) start and end point while scroll.
I try to find a way to avoid toggleClass when distance between next start point and current end end point is too short. ( want to implement toggleClass only if this distance is larger than box height )


**** Screenshot that issue happened (passed end and about to pass next start)  **** 



I was trying to achieve this with scrolltrigger's callback functions but it was too complicated and failed to get the distance between endpoint and next start point.

See the Pen bGrRWKJ by nosugarsociety (@nosugarsociety) on CodePen

Link to comment
Share on other sites

  • Solution

If I understand your goal correctly, you could run some custom logic in an onToggle like this: 

See the Pen porwrja?editors=0010 by GreenSock (@GreenSock) on CodePen


Is that what you're looking for? 

  • Like 2
Link to comment
Share on other sites

Thank you so much.

I really did not know that i can use next(), previous() and its end and start.

This is exactly logic what I have been looking for all day. 



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