Jump to content
Search Community

ScrollTrigger - Pinning child element after parent has been pinned

jimjiminyjimjim test
Moderator Tag

Go to solution Solved by elegantseagulls,

Recommended Posts

I might be misunderstanding something about scrollTrigger plugin. In this example, I'd like to pin a child element to the top of the screen as its parent leaves. I can see that the event triggers, but the fixed style doesn't seem to lock the element to the viewport?

 

How best should I achieve this?

See the Pen poePJxj by jimjiminyjimjim (@jimjiminyjimjim) on CodePen

Link to comment
Share on other sites

  • Solution

It's not working because the parent is being transformed so then the child element looses it's fixed-position context. Adding pinReparent: true, to the child element's ScrollTrigger should fix this, (you'll want to be careful when using this as you'll loose descendant styling, if applicable). More on this here: https://greensock.com/docs/v3/Plugins/ScrollTrigger

 

 

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