Jump to content
Search Community

scrollTween doesn't work on window resize

Samuele test
Moderator Tag

Recommended Posts

Hi there, I have an horizontal website and I cannot figured out why the scrollTween doesn't work if the window is resized.
Apparently the "bug" happens once an anchor link (left menu) is clicked and then the window is resized.
Does anyone else experience this problem?

Just to explain better I managed to calculate of user's scroll position once the window is resized by adding a simple function, but even if it is removed it doesn't solve the problem:

  function resize() {
    windowWidth = window.innerWidth;
    scrollContainerWidth = scrollContainer.scrollWidth;     
  }

  ScrollTrigger.addEventListener("refreshInit", resize);
  resize();


Thanks

See the Pen oNoYRrP by samuele-kriedi (@samuele-kriedi) on CodePen

Link to comment
Share on other sites

  • Samuele changed the title to scrollTween doesn't work on window resize

 

It does appear to work as expected (if I am not overlooking something obvious) on resize with the current version 3.9.1

 

See the Pen NWwbZBj by akapowl (@akapowl) on CodePen

 

However with the latest beta files of GSAP & ScrollTrigger (which you load in your codepen @Samuele) it does indeed appear to break things on resize every other time. Maybe that's something for @GreenSock or @OSUblake to have a look at.

 

See the Pen ExbNqxJ by akapowl (@akapowl) on CodePen

 

Link to comment
Share on other sites

On 2/7/2022 at 4:13 AM, akapowl said:

However with the latest beta files of GSAP & ScrollTrigger (which you load in your codepen @Samuele) it does indeed appear to break things on resize every other time. Maybe that's something for @GreenSock or @OSUblake to have a look at.

 

Thanks for pointing that out! It should be resolved now, but please let us know if you see any odd behavior. 

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