Jump to content
Search Community

How can i change the start and end trigger position when the layout changes?

Balram test
Moderator Tag

Recommended Posts

Hi,

 

I have included a codepen where i have a simple animation that turns a block to red when it enter the start position but when there is some change in layout the trigger position stays the same but i want it to change the trigger positon to where the actual trigger element is. For example i have included a another block that expands on click and when that happens the trigger position doesn't changes.

See the Pen XWyVGKr by veuxon (@veuxon) on CodePen

Link to comment
Share on other sites

For performance reasons, ScrollTrigger pre-calculates all the start/end positions so that it's super fast when scrolling. So if you CHANGE the layout after initial load, you must tell ScrollTrigger to refresh those values (recalculate them). 

ScrollTrigger.refresh();

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

 

Does that clear things up? 

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