Jump to content
Search Community

ScrollTrigger parallax header recalculating incorrectly on window resize

ekfuhrmann test
Moderator Tag

Recommended Posts

I came across what I presume to be a bug, but also could be a lapse in the way in which I'm using scrollTrigger to handle my header. Responsively the header works well across different displays on a fresh page load. That said, I run into issues when resizing the the window without reloading.

 

An example of what I'm talking about can be seen by resizing the vertical window size (viewport height). It seems like scrollTrigger isn't recalculating the depth which handles the scroll speed of that parallax layer resulting in the following:

parallax-bug.thumb.jpg.421c67a25f6b1d9d4947726ba74378e0.jpg

 

I've included invalidateOnRefresh hoping that would resolve the issue, but to no avail.
 

See the Pen poePOzd by ekfuhrmann (@ekfuhrmann) on CodePen

Link to comment
Share on other sites

Nah, it's not a bug - it's just that you're only looping through your elements once when the page loads and doing all your movement calculations based on that sizing. Use a function-based value and do the calculations inside that so whenever the ScrollTrigger refreshes and invalidates that timeline, it calls that function again and processes the new values accordingly:

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

 

Does that clear things up? 

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