Jump to content
Search Community

Pin jumps on bottom of the endpoint

DomVournias test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

  • Solution

Hi,

 

The issue is that you are pinning an element with display flex. Here you can see what the ScrollTrigger Docs:

 

pinSpacing

Boolean | String - By default, padding will be added to the bottom (or right for horizontal: true) to push other elements down so that when the pinned element gets unpinned, the following content catches up perfectly. Otherwise, things may scroll UNDER the pinned element. You can tell ScrollTrigger not to add any padding by setting pinSpacing: false. If you'd rather it use margin instead of padding, you can set pinSpacing: "margin". Note: pinSpacing works in most cases, but it really depends on the way you set up your DOM and CSS. For example, if you pin something in a parent that has display: flex or position: absolute, the extra padding won't push other elements down/right so you may need to manually space things out. pinSpacing is just a convenience that works in most situations. Important: if the container is display: flex, pinSpacing is set to false by default because that's typically what is desired since padding works differently in that context.

 

If you want to pin something don't use display flex on the element you want to pin and be careful about using pinSpacing: false in your ScrollTrigger configuration.

 

Hopefully this works the way you intend:

https://codesandbox.io/p/sandbox/small-tdd-cbgi5l?file=%2Fpages%2Findex.tsx&selection=[{"endColumn"%3A25%2C"endLineNumber"%3A19%2C"startColumn"%3A25%2C"startLineNumber"%3A19}]

 

Let us know if you have more questions.

 

Happy Tweening!

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