Fluxium Posted April 15, 2023 Share Posted April 15, 2023 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 More sharing options...
Solution GreenSock Posted April 16, 2023 Solution Share Posted April 16, 2023 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! 1 Link to comment Share on other sites More sharing options...
Fluxium Posted April 17, 2023 Author Share Posted April 17, 2023 Yes, that helps! Thank you - much appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now