Jump to content
Search Community

ScrollTrigger conditional toggleClass

nosugar

Go to solution Solved by GreenSock,

Recommended Posts

Posted

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)  **** 
 

410628279_ScreenShot2021-10-27at10_52_07PM.png.c042572cdb4dc052f7facbee5d74c3ea.png

 

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.

  • Solution
Posted

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
Posted

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

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.
×
×
  • Create New...