Jump to content
Search Community

ScrollSmoother breaks Scrolltriggers

Nick.Ls test
Moderator Tag

Go to solution Solved by Nick.Ls,

Recommended Posts

Hey everyone,

 

I was creating a similar section in my project like the one I am attaching below:

 

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

 

and it worked just fine until I imported ScrollSmoother. Adding smoother seems

that it breaks the end points (?). Attaching codepen with smoother added as

reference too.

 

 

P.S. In my website setting the pinSpacing to true seems to make things a bit better but still out of sync.

 

Any ideas? Thank you in advance!

See the Pen RwJzgPg by Nick_Ls (@Nick_Ls) on CodePen

Link to comment
Share on other sites

Hi,

 

Everything seems to work in the exact same way with or without ScrollSmoother in the mix:

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

 

I made a few tweaks in order to give scroll space before and after the cards section and removed the margin in the body tag (I would recommend not to do that). If you comment-out the ScrollSmoother section of the code the markers are in the same position and everything works in the same way.

 

Maybe I'm missing something here, but everything seems to work the way is supposed to. If the example above is not working for you, please be more specific about what you intend to do.

 

Happy Tweening!

Link to comment
Share on other sites

Hi @Rodrigo,

 

Thanks for your reply. You are right in most of it. Giving it some space indeed works better. The margin on body top is just some space which I don't actually use in my live project.

 

I have tried the above setup with infinite variations ( 😋 ) at this point to make it work in the most optimal way but in every situation I keep coming across with the same problem. The scrolltrigger height is not calculated properly in every refresh of the page.

 

Same applies to your codepen too... Check the image I am attaching below.

 

image.thumb.png.1eaad47e95c859eda98aaa7d36d25382.png

 

The 3rd card does not pin exactly at the same position as the others and the Scrolltrigger end event fires a bit sooner giving us with the above result.

Refreshing the page you'll notice that it fixes the problem but refreshing the page is not a solution.

 

I was thinking of a doc ready function before initialization in order to have the content loaded before letting the scrolltrigger calculate the height might work...

 

Any other ideas?

Link to comment
Share on other sites

  • Solution

Giving a solution on the problem if someone ever comes up with something similar.

 

On ideal scenarios page load speed, DOM elements, js files etc run optimal or are precached so the scroll will occur as intended. On the other hand it looks like in a real scenario the images I have placed create the scrolling height and all the elements must be already loaded to calculate everything correctly. Therefore I used imagesloaded.js where I run the scrolltriggers AFTER the images on the section are loaded and everything works like a charm.

 

Hopefully it can be a solution to someone else too out there.

 

Once again, thanks @Rodrigo for the time spent looking into it and this amazing community / forum!

 

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