Jump to content
Search Community

Pinned section with horizontal scrolling

n00bie test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hello, I spent a lot of hours on this and I can't find the solution so I'm turning this over this active community to help me out. Basically I know the problem comes from the "end" parameter after playing around but I'm puzzled. I would like for when my horizontal scrolling section is done scrolling, to have enough time to see the "GSAP Left to Right" section's animations. If I scroll super slowly I can see them, however if I scroll very fast I can't. Any idea on how to solve this? Thanks!

 

Also, any way to have my "Item 7" to show up inside the container, depending on the resolution it's not always fully visible 😇

 

See the Pen ExMJjeG by theintegrateur (@theintegrateur) on CodePen

Link to comment
Share on other sites

2 hours ago, n00bie said:

I would like for when my horizontal scrolling section is done scrolling, to have enough time to see the "GSAP Left to Right" section's animations. If I scroll super slowly I can see them, however if I scroll very fast I can't. Any idea on how to solve this? Thanks!

scrub: true is one way to solve this. You'll loose the smoothing effect, but it'll tie the animation directly to the scroll, otherwise it's taking .8s for the animation to catch up, and if you scroll too fast, you're missing the end.

 

2 hours ago, n00bie said:

Also, any way to have my "Item 7" to show up inside the container, depending on the resolution it's not always fully visible

Your math isn't accounting for the 64px gap. You'll want your math to be: (offerItems[0].offsetWidth * offerItems.length) - (64 * (offerItems.length - 1))

  • Like 2
Link to comment
Share on other sites

11 hours ago, ryan_labar said:

scrub: true is one way to solve this. You'll loose the smoothing effect, but it'll tie the animation directly to the scroll, otherwise it's taking .8s for the animation to catch up, and if you scroll too fast, you're missing the end.

 

Your math isn't accounting for the 64px gap. You'll want your math to be: (offerItems[0].offsetWidth * offerItems.length) - (64 * (offerItems.length - 1))

Hey @ryan_labar thank you so much!

 

For the spacing, instead of using flex's gap, should I use padding or margin so that it is calculated in the offsetWidth and so, if the designer want to change the spacing from 64px to something else, I don't have to play around in the JS? I updated the Pen but I don't seem to get the math working, on desktop view it looks good, but smaller, the last item is not fully visible.

 

Link to comment
Share on other sites

@Rodrigo if I could kiss you, I would, thank you so much it looks like it's working with you and Ryan's help. Last detail, If I want the scroll to be slower, "duration" doesn't seem to impact anything, I guess it would be to add scrub: 1 but that will break the animation coming after this one like Ryan mentionned, any workaround or it's just the natural scroll speed that is applied?

Link to comment
Share on other sites

@Rodrigo It indeed answered my question, however when changing the "end" parameter to let's say "+=2000px" instead of "+=bottom 50%" the next section's animation already occured. If you could point me in the right direction that'd be awesome! :)

Link to comment
Share on other sites

Hi,

 

Sorry to hear about the issues, but without a minimal demo there is not a lot we can do. As you can see the demo I created works as expected and nothing breaks on window resize, so something else must be interfering with your app and is breaking things upon window resize.

 

Happy Tweening!

Link to comment
Share on other sites

Good morning @Rodrigo, the problem seems to be happening only if "invalidateOnRefresh" is set to true. On my local development site, I only kept the GSAP code for my animation (no other JS) and the problem is still happening. I'll try to dig deeper... Thanks! :)

 

Edit: Even with another pinned section the problem occurs it's super weird, the pinned section on resize gets repinned to almost the top of the body.

 

https://www.loom.com/share/674c773293d841faa1d66d75e5537e14

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