Jump to content
Search Community

SmoothScroller's element stops moving at a certain point when used with CSS grid

skadoosh test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I'm trying to create a layout where images are scatter around and overlap each other using CSS grid and apply different data-speed to make it looks parallax by using smoothscroller.  This works fine with flexbox but when I used with CSS grid, Image start to move until it hits the top of viewport and then it stop moving. In demo, you can clearly see how the second image stop moving when it hit the top of viewport. This seems weird because when I used with flexbox it works perfectly.

See the Pen JjpmvzN by skadooshmp (@skadooshmp) on CodePen

Link to comment
Share on other sites

  • Solution

That's because the ".item" elements are actually much shorter than you think they are :) Try setting a border on them and/or overflow: hidden and you'll see what I mean. 

 

So ScrollSmoother is doing its job of only animating those while they're in the viewport...but you've got nested images in there that are still on-screen when the items are technically outside the viewport. 

 

So you'll need to either adjust your CSS/layout so that the images are fully contained within those ".item" elements or just put your data-speed on the images themselves instead of their container(s). 

 

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

  • Like 1
Link to comment
Share on other sites

Thank you so much for pointing this out. I've some problem when applying data-speed on gatsby-plugin-image component in my real project so I have to wrap image with div and add data-speed on it. Haven't think that would cause a problem my bad 🙏

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