Jump to content
Search Community

scrollTrigger snap is not working properly

codechirag test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hello GSAP Family, It's always pleasant working with GSAP and today while doing so I have got an issue with scrollTrigger snap. I was working with functionality for which Snap is required and I have tried to add it but while I scroll down the snap goes back to previous section and not moving forward. Here is the pen. Please help me guys.

 

See the Pen ExzNVgz by EmpChirag (@EmpChirag) on CodePen

Link to comment
Share on other sites

  • Solution

You don't want to create a function of the snap value snap: () =>  1 / 4  snap: 1 / 4. Your code will calculate the value and then snap to that value eg 0.25, but I think you want to snap it to increments of 0.25 eg 0, 0.25, 0.5, 0.75, 1 which you get if you just feed it 1 / 4. When working with snap you can also feed it an array and thus just hard code the values, this is something I always like to do, to test if the math I'm using is correct with the values I want to get snap: [0, 0.25, 0.5, 0.75, 1] it is always a good idea to test your logic. Hope it helps and happy tweening! 

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