Jump to content
Search Community

ScrollTrigger not delaying within pinned element

Caleb V test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I've got a setup basically like the CodePen example. A pinned element with other elements that should animate in once they reach the middle of the screen.

 

The problem is, when I've pinned the parent for a bit, it throws off the child's trigger.

 

Do I need to manually adjust the trigger to compensate for this? Or is there a way to have it trigger when the child element actually reaches the center of the screen?

See the Pen KKWNBzZ by calebvetter (@calebvetter) on CodePen

  • Like 1
Link to comment
Share on other sites

  • Solution

Welcome to the forums, @Caleb V! And more importantly, thanks for providing such a fantastic minimal demo! It makes things so much easier to see and troubleshoot. 🙌

 

Yeah, that's a pretty tricky scenario. Typically it's best to build your page in a way that lets you pin stuff separately (don't pin an element that also has other ScrollTrigger elements nested inside of it) but maybe that's not an option for you. I have two solutions: 

 

1) Use a function-based "start" value that has the adjustment baked in: 

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

 

2) I'll likely add a pinnedContainer special property to the next release that let you specify the pinned container so that ScrollTrigger can offset values accordingly for you. I'm not 100% sure that'll be the final name, but it's the most intuitive one I could come up with. 

 

Here's a demo that uses the beta version:

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

 

Does that help? 

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