Jump to content
Search Community

Pin Element issue

Adesh test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

I noticed a few problems: 

  • You were using an endTrigger of ".collapse--group" but there was no such element
  • If you want them to stack so that the 2nd one pins UNDER the first one, etc. (I hope I'm assuming correctly), you must offset their start value accordingly based on their height. For example, if they're all 50px tall, the first one would pin at 0, the second one at 50, the third at 100, etc.
  • I don't think you want to unpin when that element's bottom hits the bottom of the viewport ("bottom bottom") - I assume you want it to unpin when the bottom of the last pinned element hits the bottom of that container section. 
  • To make it responsive, you'd need to use function-based start/end values and do your recalculations of the offsets in a "resize" listener.
  • There's an odd browser rounding issue that can cause your flexbox layout to wrap differently when you do pinning because ScrollTrigger gets the width from the browser which reports it in px, but you're using 40% and when the browser converts that to px it's rounding up which can make it about 1px too wide, causing the wrap. So I set a style in the CSS for the .pin-spacer so that it's forced to be 40%. 

Is this more like what you wanted?:

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

 

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