Jump to content
Search Community

Pin text from top to bottom inside ScrollSmoother content

Akamiaxx test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hello GSAP Community,

I am trying out ScrollSmoother with ScrollTrigger and I would like to have my title to be "pinned" at the center of the page while scrolling, from to to bottom. 
The problem is that I get a weird spacing below my page content, when I am using the pin option with ScrollTrigger. Tried to set the pinSpacing to false but I still get an extra plus spacing.

Here are screenshots of what I get (first) and what I am expecting (second) :

You can also find the demo on codesandbox here : https://codesandbox.io/s/bold-shadow-in3nnw
 

Thank you!

Capture d’écran 2023-02-19 à 9.36.39 PM.png

Capture d’écran 2023-02-19 à 9.36.29 PM.png

See the Pen by s (@s) on CodePen

Link to comment
Share on other sites

  • Solution

Then just set position: absolute on your cover element: 

https://codesandbox.io/s/affectionate-tereshkova-cnfoc4?file=/src/index.js

 

The problem is that when you pin an element, it has to wrap it in an element that has position: relative in order to do proper positioning and prop things open in the layout, but you're using position: fixed so when that gets overridden, that element goes into the document flow (taking up space) and that's the extra space you see at the bottom. Setting it to position: absolute takes it out of the document flow. 

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