Jump to content
Search Community

ScrollTrigger pin-spacer large screen

jrh test
Moderator Tag

Recommended Posts

Hey there,

 

Just wondering if I'm doing something glaringly wrong here.. Try and use a pinned horizontal scroll section, but the .pin-spacer element seems to add loads of height/padding bottom and throws out the layout of the page, particularly on wide monitors. But also happens on mobile when I reduce the size of the images in the horizontal section.

 

I've attached screenshots showing the layout with scrollTrigger on and off. As you can see the footer is pushed way down the page when initialised.

 

Essentially I just want those images to scroll horizontally then carry on scrolling normally at the end of the section.

 

Let me know if there's anything else I might need to share.

 

Cheers!

 

st-off.png

 

ScrollTrigger enabled:

st-on.png

See the Pen ExbWOOL by j-rh (@j-rh) on CodePen

Link to comment
Share on other sites

Welcome to the GSAP forums @jrh

 

8 minutes ago, jrh said:

the .pin-spacer element seems to add loads of height/padding bottom and throws out the layout of the page

 

Yup, that is how the pin-spacer works. If you do not want any pinSpacing to show, I'd recommend wrapping all your content in a div and pin that div instead.

 

See the Pen qBVrLRG by akapowl (@akapowl) on CodePen

 

 

Note, that for potential subsequent ScrollTriggers within that same container you will need to use the pinnedContainer property to make them have their starts and ends set to where you'd expect them to be.

 

pinnedContainer Element | String - If your ScrollTrigger's trigger/endTrigger element is INSIDE an element that gets pinned by another ScrollTrigger (pretty uncommon), that would cause the start/end positions to be thrown off by however long that pin lasts, so you can set the pinnedContainer to that parent/container element to have ScrollTrigger calculate those offsets accordingly. Again, this is very rarely needed. (added in 3.7.0)

 

Hope that'll help - happy scrolling!

 

 

  • Like 2
Link to comment
Share on other sites

Hey @akapowl thanks for the welcome and the quick reply!

 

So using this kind of pinned section in a page with a header, hero banner, other elements above and below plus a footer I need to wrap and pin the entire page?

 

Are there any performance issues associated with this? Feels a bit like overkill, but I'll give it a try.

Link to comment
Share on other sites

3 minutes ago, jrh said:

So using this kind of pinned section in a page with a header, hero banner, other elements above and below plus a footer I need to wrap and pin the entire page?

 

You wouldn't have to pin the the entire page - technically only those sections of the page that might be visible above and below that fake-horizontal section of yours at any point.

 

5 minutes ago, jrh said:

Are there any performance issues associated with this

 

I don't think there should be any performace issues, as you are not animating all of that.

 

  • Like 2
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...