Jump to content
Search Community

Using ScrollTrigger for horizontal scrolling sections

servus test
Moderator Tag

Recommended Posts

Good morning from Austria!

I am very new to GSAP and i would be thankful if anybody could help me with my first issues.

 

As starting point i am using this example:

 

On scrolling i have that issue that the actual section is not immediately "snap" on the left site, it seems that it have any delay. Does anybody have an idea please?

 

Thanks!

 

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

Link to comment
Share on other sites

1 hour ago, servus said:

On scrolling i have that issue that the actual section is not immediately "snap" on the left site, it seems that it have any delay. Does anybody have an idea please?

It waits for scrolling to end before snapping. Otherwise, it would be fighting with the user for control over the position. You can make the actual snapping part faster if you prefer by setting a duration like snap: { duration: 0.1, snapTo: 1 / (sections.length - 1) } but it still needs to wait for scrolling to stop first. 

 

Thanks for being a Club GreenSock member! 🙌 

  • Like 2
Link to comment
Share on other sites

Thanks for helping! If i use your settings and play with it, the snapping is too hard. Do i have another chance to solve the horizontal scrolling with ScrollTrigger similar to a slider?

Link to comment
Share on other sites

Thanks Cassie! That´s what i am looking for, but in combination with pin. I have a header, main and footer section. The slider comes into main, when finishing scrolling with last slide i should be able to scroll further to footer. Is this possible with your example?

  • Like 1
Link to comment
Share on other sites

Literally anything is possible with enough thought, time and custom logic applied to the problem. But unfortunately we don't have the resources to build out complete solutions in these forums.

We have a new plugin 'Observer' which may make your life easier - but Observer only observes events. It'll be up to you to write the custom logic to handle how the page behaves. Demos like this are tricky because you're taking control away from the user so a lot of thought has to go into different types of navigation. What if they're using mouse wheel, spacebar or touch screens to navigate? How do different browsers handle it?

Here's an example using observer and scrollTrigger so you can see a basic example of how you'd mix the two.

See the Pen 1ccf60146d680c09ba6074bf9132778d by GreenSock (@GreenSock) on CodePen



Hope this helps, good luck!
 

  • Like 1
Link to comment
Share on other sites

  • 8 months later...
On 6/7/2022 at 8:06 AM, Cassie said:

Literally anything is possible with enough thought, time and custom logic applied to the problem. But unfortunately we don't have the resources to build out complete solutions in these forums.

We have a new plugin 'Observer' which may make your life easier - but Observer only observes events. It'll be up to you to write the custom logic to handle how the page behaves. Demos like this are tricky because you're taking control away from the user so a lot of thought has to go into different types of navigation. What if they're using mouse wheel, spacebar or touch screens to navigate? How do different browsers handle it?

Here's an example using observer and scrollTrigger so you can see a basic example of how you'd mix the two.
 

 


Hope this helps, good luck!
 

 

 

Is there a way to "snap" to the first red section. Unless I'm extremely careful with my scroll, the red section will always scroll past into the next purple section. It would be great if there was a way to make that a bit smoother. 

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