Jump to content
Search Community

Horizontal Loop Helper function Z-index not on the same level

I_dont_know test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hello !

I'm quite new here so I hope it's a Gsap related problem and not just logic on my end.

I'm using an Helper function called horizontalLoop() and i use it to display text like a marquee that can be dragged and scrolled, the problem I have is that even if I change the Z index of my text the text is not on the same level which make it hard to add other content that go behind some element. I cant provide a demo but on the screenshot I hope you can see the problem. If the author of the function know the cause of this or someone else.

Thanks in advance if you try to help me !

.Gsapforum.png.09efa8ee5f0ccde941cf7f82a65ca627.png

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

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

 

If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt.

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

Hi,

 

The helper function does offer a series of config options. In this case the paddingRight option:

let loop = horizontalLoop(".item", { repeat : -1, paddingRight: 30 });

That seems to solve the problem in your codepen example.

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Thanks for the answer, but i tried ur soluce and found that the problem was still here because this is the 3d view i get and i know that at a point one element will go over the other if I add an image (which is the final goal but my pen is minimal just to showcase the problem). I dont know if a solution using Gsap can be used maybe i will have to try to do it in another way 😓.

Capturedcran2023-05-02190234.png.fa7317d9243d2c56dba40615c04a2ee1.png

Link to comment
Share on other sites

@I_dont_know if you'd like more help, please make sure you provide a minimal demo that clearly illustrates the problem and we'd be happy to answer any GSAP-specific questions. The helper function is just intended to help folks - it's not something we "officially" support. If there are any obvious flaws, though, I'd like to resolve those. It's not made to be 3D, just so you know. 

  • Like 1
Link to comment
Share on other sites

Ok sorry getting confused with codepen and Gsap excuse me.

I improved the demo to showcase what i try to explain with only text and the problem is still here.

See the Pen BaqwYJL by Niesmer (@Niesmer) on CodePen

 

So the problem i get is that when you hover on the last project 10 (the last one of my item) it goes over project 1 which is what i'd like to avoird i wanted the image to go underneath all my link I hope i'm explaining myself and sorry for being slow.

Link to comment
Share on other sites

  • Solution

If I understand you correctly, that's a logic issue - you want the next one to the right to always have a higher z-index value, but you're looping around so that the first one comes after the last one. So 10 must be higher than 9...and 1 must be higher than 10? 

 

Two ways I can think of to solve it is to add set() calls to the resulting horizontalLoop() timeline so that the zIndex values shift at the appropriate spots, -OR- you could just add logic to your mouseenter handler so that at that point it sets the next element's zIndex to a higher value, and maybe on mouseleave revert it. 

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