Jump to content
Search Community

Infinite roller

xoxoxoxo test
Moderator Tag

Recommended Posts

I'm trying to achieve an effect like this, the panels auto roll but also are controllable from mouse scroll.

 

I've tried to re-create this using the wrap() function however there is always a "gap" between. Also, I had to turn off `autoRefresh` flag because it was resetting every time it repeated.

 

How do I fix the gap and How do I also control it from the mouse?

See the Pen BaLNMeq?editors=1010 by nullhoooook (@nullhoooook) on CodePen

Link to comment
Share on other sites

Hey nullhook.

 

Most likely you will need to pause any animation of the content while the user scrolls. Then start it again once scrolling has scrolled. You probably want to listen for the wheel event and, if you want to support touch devices, either use draggable or something like HammerJS to add touch support. 

 

Unfortunately we don't have the capacity to debug projects like this for free. Or maybe someone else who is able to help out will stop by.

 

If you have a question about GSAP itself we're happy to help!

Link to comment
Share on other sites

Yep, it's a logic thing. You're using one repeating tween and the same modifier for everything but you actually have your elements staggered in various positions on the x-axis, thus you must adjust for that. In other words, the very first element could wrap when it hits -window.innerWidth, but the second element would have to wait until 2 * -window.innerWidth, etc. 

 

Here's an option: 

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

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