Jump to content
GreenSock

BruceST

How to recalculate ScrollTrigger Start and End after an element resize?

Go to solution Solved by Sam Tremblay,

Recommended Posts

Hello guys, I'm new to GSAP

 

On my page I have I have a few sections

I resize the height of the first section immediately after the page load using gsap.to

 

The subsequent section have scroll triggers.

However the start and end of each section is still based on the values before the resize of the initial element

I believe I need to use ScrollTrigger.refresh() to recalculate, but I'm not sure where to put it, see my codepen example

 

Any help would be appreciated...

See the Pen mdjpxaX?editors=0111 by bruce-persaud (@bruce-persaud) on CodePen

Link to comment
Share on other sites

  • Solution

Hi @BruceST!

 

On your gsap.to that control your .one-one height, add this parameter:

onComplete: () => {
    ScrollTrigger.refresh();
}

 

See the Pen OJwzwmz by sam-tremblay (@sam-tremblay) on CodePen

 

Happy Tweening!

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