Jump to content
GreenSock

Cartos

Horizontal scrolling overlapping the previously added dynamic sections

Recommended Posts

Hi All, 

 

Horizontal scrolling section overlapping the dynamic added content. I tried with ScrollTrigger refresh as well, but it didn't work for me either. 

Check here my codepen url : 

See the Pen VwQEBvJ by cartos (@cartos) on CodePen

 
You can see the problem in full view mode using this url : 

Please help where I am making mistake. 

See the Pen VwQEBvJ by cartos (@cartos) on CodePen

Link to comment
Share on other sites

Hi there I'm not seeing an issue, could you explain a little further? Thanks

 

 

Link to comment
Share on other sites

Hi did you get  some time to check my video. 

I have some dynamic sections which are populating from response. And in last I have horizontal sections as well which are scrolling on scroll. 

 

Now the problem is, sometimes horozontal scroll is not waiting for dynamic sections to be populated and appearing before/overlapping dynamic sections. 

 

Link to comment
Share on other sites

That looks to me like you are dynamically loading data in AFTER the page loads and it is affecting layout (throwing off the start/end positions of the ScrollTriggers), so make sure you call ScrollTrigger.refresh() after you're DONE affecting layout. Perhaps here:

fetch("https://reqres.in/api/users?page=1")
      .then((res) => res.json())
      .then((json) => setUserData(json.data))
      .then(() => ScrollTrigger.refresh()); // <- HERE!

Does that help? 

  • Like 3
Link to comment
Share on other sites

Thanks, thats all I wanted. 

 

But it is a solution to part of the problem. There is also a problem with the horizontal section. In the first section, I am populating the data from the API, which width can be anything as I am populating all the data in one row. Now after populating you can see that the last section of the horizontal bar is sometimes not visible and sometimes it is not moving to the left as expected.
 

Link to comment
Share on other sites

Are you sure you're calling ScrollTrigger.refresh() afterwards and updating the width of that section?

I noticed you're using selector text and normal variables too, which is usually a bad idea in React. We have this guide here which may help you.
 

  • Like 1
Link to comment
Share on other sites

34 minutes ago, Cassie said:

Are you sure you're calling ScrollTrigger.refresh() afterwards and updating the width of that section?

 

I am calling ScrollTrigger.refresh() only after json response. I do not know how we can calculate the width of that section as that will be increasing on length of response data.

Link to comment
Share on other sites

Thanks for your help. I updated my pen and horizontal sections look working now. But sometime last section is flickering. 

 

See the Pen VwQEBvJ by cartos (@cartos) on CodePen

  • Like 1
Link to comment
Share on other sites

I can't see the flicker. Do you have steps to reproduce it or any more information?

Link to comment
Share on other sites

Hold on to the last section, a little before of end, around 95%. The last section tries to go left automatically and thats where it flickers

Link to comment
Share on other sites

We love helping with GSAP-related questions, but unfortunately we just don't have the resources to provide free general consulting, logic troubleshooting, or "how do I recreate this cool effect I saw on another site?" tutorials. Of course anyone else is welcome to post an answer if they'd like - we just want to manage expectations.  

 

You can post in the "Jobs & Freelance" forum for paid consulting, or contact us directly. 

 

Otherwise, if you've got a GSAP-specific question just post that here along with a minimal demo and we'd be happy to take a look. 

Link to comment
Share on other sites

5 minutes ago, Cassie said:

There's no issue for me! Looks a ok. Maybe you're looking at it in an iframe or on a bad connection.

Thank you so much @Cassie Great help so far. I got the solution. It was network connection

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