Jump to content
Search Community

Anchor links and scroll snapping

Wemnia test
Moderator Tag

Recommended Posts

Hello everybody,
I have recently started using GSAP, and I am still inexperienced in using it. However, I am happy to have become part of this community!


I am creating a page in which I would like to insert a smooth scroll snapping, and also use a smooth scroll for the navbar anchor links that lead to the various sections of the page.

As you can see from my Pen I created, everything seems to work fine, but there are some problems that I can't solve:

 

- If while scrolling in one direction with the mouse wheel, before the animation ends, I start to rotate the mouse wheel in the opposite direction, sometimes "jumps" will occur, towards the new section, instead of still perform a smooth scroll.

- If I use the menu links to reach a section (obviously without using the mouse wheel), a strange error occurs and I am not taken to the correct section (this did not happen before implementing the scroll snapping system).

 

Can you help me to solve these annoying problems? Tips are also welcome to make my JS code better and more performing.😊

 

Thank you!

See the Pen dyOVPWP by Vallo92 (@Vallo92) on CodePen

Link to comment
Share on other sites

Hey Wemnia and welcome to the GreenSock forums. Thanks for supporting GreenSock with a Club GreenSock plugin!

 

ScrollTrigger and the ScrollToPlugin are not built to support scroll-jacking like what you're doing here. At this point we don't officially support it. For more information and a more in-depth approach, see this thread:

 

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