Jump to content
Search Community

Recalculate tween duration on window resize

Mitya Kobrinsky test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi!

 

I'm trying to make several panels appearing one by one and scrolling down if needed. So I calculate y-shift and duration for each panel by function, based on panel heights. And it works... partially. When I resize the window, y-shifts are recalculating, but durations aren't. Now if big panel, which didn't need scrolling, became small and does need it now, it just jump from start position to end, because duration is still zero :(

 

What is the best way to refresh durations?

See the Pen NWgmpyv by mityakobrinsky (@mityakobrinsky) on CodePen

Link to comment
Share on other sites

Hi Mitya!

 

Durations can't be recalculated. It'd really mess up the sequencing if they could.

 

So you'd need to kill your ScrollTriggers and make them again if you need different durations. If you create your ScrollTriggers inside matchMedia, it will do that for you.

 

https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.matchMedia()

 

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