Jump to content
Search Community

ScrollSmoother does not recalculate body-height after DOM-injectoin

marvet test
Moderator Tag

Go to solution Solved by marvet,

Recommended Posts

Hi there,

 

we've started using the GSAP ScrollSmoother in one of our projects, what actually works fine. This project is a SPA, so all pages are loaded via AJAX and the pre-rendered HTML is injected into the page/DOM. In some cases, ScrollSmoother recalculates the height of the body correctly after the injection, in other cases the body's height is set to 2000px. The function of loading and injecting is always the same, even the contents (markup) are similar.

 

Does anybody have a clue? 

 

Thank you in advance.

Link to comment
Share on other sites

Thank you for your quick reply.

 

You're pointing on ScrollTrigger, but in our case its's ScrollSmoother which causes the issue. We've tried adding your solution but it didn't had any effect. Also we've verified if the height is beeing calculated by ScrollTrigger (which we are also using in this project) or ScrollSmoother and it's latter.

 

Somehow, only in some cases the height is not calculated correctly, in others it is.

Link to comment
Share on other sites

  • Solution

UPDATE

 

Got it. It's not an issue with ScrollSmoother (or ScrollTrigger) which actually works perfect. We had a situation which was blocking the correct calculation. The good thing about this... now we know, that ScrollSmoother automatically update the body's height after changes to it. :-)

Link to comment
Share on other sites

10 minutes ago, marvet said:

You're pointing on ScrollTrigger, but in our case its's ScrollSmoother which causes the issue.

 

ScrollSmoother is just a complex ScrollTrigger, so ScrollTrigger.refresh() will update it. Notice how it doesn't update if you comment out the refresh call in the click handler.

 

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

 

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