Jump to content
GreenSock

chetan9477

On scroll down or scroll up or even on click gsap snapping not allowing to add active class to sticky side menu

Moderator Tag

Recommended Posts

based on the scroll of the section I am adding an active class to the sticky menu by targeting href element through JS but while scrolling to Overview section which is a snapping section based on scroll trigger its not allowed to add an active class in the sticky menu of overview. 

Screenshot 2023-06-07 at 10.32.45 PM.png

See the Pen by pen?template=oNQNyyV (@pen?template=oNQNyyV) on CodePen

Link to comment
Share on other sites

Hi,

 

I don't have time to go through all the code you have there and find a way to create a solution for that specific case, but I can advice you to create a simple ScrollTrigger instance for every section. Since the number of sections is the same as the number of sidebar elements, you can easily tap into ScrollTrigger callbacks and update the styles or classes of the sidebar elements.

 

Here is a super simple example of that approach:

See the Pen oNQNrQx by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

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.
×