NickNo Posted April 28, 2023 Share Posted April 28, 2023 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 More sharing options...
Solution GreenSock Posted April 28, 2023 Solution Share Posted April 28, 2023 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). 1 1 Link to comment Share on other sites More sharing options...
NickNo Posted April 30, 2023 Author Share Posted April 30, 2023 Perfect thanks Jack, thanks for the quick & clear response. In my actual project, the pinning jumps even at fairly slow scroll speed (unlike the codepen demo where it is a solid pin). Any idea why this would be happening? Screen Recording 2023-05-01 at 9.13.59 AM.mov Link to comment Share on other sites More sharing options...
GreenSock Posted May 1, 2023 Share Posted May 1, 2023 Sorry, @NickNo - it's very difficult to know by just watching a video. We really need to see a minimal demo that clearly illustrates the problem in order to troubleshoot. Maybe you've got a lot of graphics that are bogging down the browser rendering-wise? You can try the anticipatePin feature, but it can't work miracles. 🤷♂️ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now