Jump to content
Search Community

Scrolltrigger - pinning in place

NickNo test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi, I have this filter element that I want to pin in the navbar once I scroll to it - but can't figure out how to get it to stick - do I use ScrollTrigger pin, or do I have to fix it in css?  I want it to shrink to size as I scroll up to the navbar and then sit inside the orange box...

See the Pen KKGqQrr by nickjacobsnz (@nickjacobsnz) on CodePen

Link to comment
Share on other sites

  • Solution

I assume you were looking for something like this: 

See the Pen abRwavV?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Just use a different ScrollTrigger for the pinning, and leverage a wrapper so that you're not pinning the same thing that you're animating and applying transforms to. Also, you've got big margins on the element you're pinning, so to avoid margin collapse you should put either a 1px padding on the container or a transparent border (either one prevents the margins from leaking out of the container). 

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