Jump to content
Search Community

Official horizontalLoop helper function - previous/next item doesn't animate properly if first/last item is already partially visible?

niceandserious test
Moderator Tag

Recommended Posts

Hi guys, first off thanks so much for all the awesome work you do! 🙂

I've been using the official horizontalLoop helper function to build a carousel. However, I've noticed that if the last item in the carousel is already partially visible due to the width of the carousel vs the number of items, then clicking the previous/next buttons causes the next item to 'jump' rather than animate, which is understandable as we're translating rather than duplicating elements:  - depending on your screen size you may need to comment out more items.

 

Is there a way of adding a clamping/'toEnd' function that could check for this and partially animate the carousel so it just animates in the rest of the partially visible item?

 

Hope that makes sense, let me know if not!

 

Screenshot2024-06-25at12_45_43.thumb.jpg.3e9ccd53f0ab5f33a5bd2a5caeabadbb.jpg

Screenshot2024-06-25at12_46_12.thumb.jpg.d984f2a03892f45acb9a3ba3ac34c6c6.jpgScreenshot2024-06-25at12_46_19.thumb.jpg.d7f798a62fc9d04892f1e79f0ebc1e66.jpg

See the Pen VwOddYb by niceandserious (@niceandserious) on CodePen

  • Like 1
Link to comment
Share on other sites

Heya!

 

I would say that if your carousel is going to be wider than the number of items, then this likely isn't the right solution and you should probably go with a solution that duplicates elements?

 

But also, I'm afraid this helper function is beyond my understanding, it's @GreenSock's work - so maybe he has an idea or advice?

 

Link to comment
Share on other sites

As far as I know the Seamless Loop helper predicates in the fact that all the remainder elements will cover all the available space in it's parent when the first element is out of the view, which is not the case in your images.

 

Honestly IDK how that could be worked around. As Cassie mentions this is something Jack came up with so he would be the one to say the final word on this subject, but if I recall correctly something similar to your situation has popped up in the forums in the past and I believe there is not a lot that can be done without duplicating the elements.

 

Happy Tweening!

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