Jump to content
Search Community

horizontalLoop() function, make item not centered when using toIndex()

Fluxium test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey all,

I've been playing around with the horizontalLoop() helper function and wanted to add some extra functionality.

There is already the toIndex() function that you can call, that will scroll to a selected element, centering it in the container.

How could I modify the code so that the item doesn't get centered but instead the left edge of the item is at the containers center?

 

I was thinking about duplicating toIndex() calling it toIndexStart(), but then I'm not exactly sure what to change to achieve what I want.

I'm sorry if this question is too much logic / JavaScript related.

 

Appreciate any help! Thanks!

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

Link to comment
Share on other sites

  • Solution

Yeah, that's kinda beyond the scope of what we can provide in these forums for free but I did a quick glance at the code and changed one line so that it always aligns the left side of the indexed element with the center of the container: 

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

 

Does that help? If you need more assistance, you're welcome to reach out to us for paid consulting services.

 

Good luck with the project!

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