Jump to content
Search Community

ScrollTrigger directional not working in this case?

Tazintosh test
Moderator Tag

Recommended Posts

Hi folks,

 

I've updated to GSAP 3.8 and reviewed my code to add directional: true (even it's by default) to my snap object.

I cannot achieve to get the result described:

Quote

• directional [Boolean] - by default (as of version 3.8.0), snapping is directional by default meaning it'll go in the direction the user last scrolled, but you can disable this by setting directional: false.

 

What am I missing?

Thanks in advance.

See the Pen NWvXrYe by Tazintosh (@Tazintosh) on CodePen

Link to comment
Share on other sites

Here's your problem: 

snapTo : [0.5]

You only have ONE value for snapping. So direction won't matter!

 

For example, if you had snapTo: [0, 0.5, 1] and when you stop scrolling it's at 0.6...

  • normal snapping (non-directional) would go to the CLOSEST value (0.5 in this case)
  • forward directional snapping would go to the next closest value in the positive direction (1 in this case)
  • backward directional snapping would go to the next closest value in the negative direction (0.5 in this case) 

So if there's literally only one number in the Array, that's the only possible option to snap to. 

 

Does that clear things up? 

 

Here's how I'd probably handle what [I think] you're attempting to do: 

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

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