Jump to content
Search Community

Calculating progress on autoplaying looping draggable slider

mitchellcliftonbarton test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

I built this little slider based off of the codepen below, and have added a few tweaks.

 

See the Pen ZOgGXB by osublake (@osublake) on CodePen

 

The slider starts automatically, and then on mouseenter/mouseleave the animations pauses or plays. Once paused, you can drag through the carousel as you please, until you mouseleave again at which point the slider will resume playing from where you left off. 

 

The only problem I am running into is figuring out the actual progress value once I start dragging. I figured I would have to grab the current progress, and then add the dragging progress to it, but this results in some crazy dragging stuff. 

 

Any ideas on how I can seamlessly maintain the correct progress value between the autoplay and the dragging?

 

See the Pen mdwJMbo by mitchellcliftonbarton (@mitchellcliftonbarton) on CodePen

Link to comment
Share on other sites

  • 1 year later...

Is it possible to have this functionality added onto an infinitely looping marquee where the draggable function will just "animate" the timescale/progress/something that will gradually increase speed of the marquee and then gradually go back to initial speed?

 

I've been trying to achieve this for quite a while now and though to look for assistance—thanks!

Link to comment
Share on other sites

Sure, something like that is doable but it's way beyond the free help we can offer in these forums. It'd take quite a bit of custom logic to wire up but as far as I can tell it should be possible. Feel free to contact us if you'd like to explore paid consulting services. All the basic mechanics should be in that demo that Blake posted earlier - it's just a matter of tweaking that. Here's a fork that's a few steps in that direction: 

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

Link to comment
Share on other sites

  • 8 months later...
On 8/27/2021 at 2:09 AM, mitchellcliftonbarton said:

I built this little slider based off of the codepen below, and have added a few tweaks.

 

 

 

 

The slider starts automatically, and then on mouseenter/mouseleave the animations pauses or plays. Once paused, you can drag through the carousel as you please, until you mouseleave again at which point the slider will resume playing from where you left off. 

 

The only problem I am running into is figuring out the actual progress value once I start dragging. I figured I would have to grab the current progress, and then add the dragging progress to it, but this results in some crazy dragging stuff. 

 

Any ideas on how I can seamlessly maintain the correct progress value between the autoplay and the dragging?

 

Need this Right <-- Left? what can i do?

Link to comment
Share on other sites

Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? 

 

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

 

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

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

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

15 hours ago, Rodrigo said:

Hi @August Devices,

 

Is really unclear what you're asking for, so my best guess is that you may be looking for the reverse config option:

const loop = horizontalLoop(items, {
  reverse: true,
});

Happy Tweening!

Thank you got Quick help


When mouse hover animation pause and mouse leave play?

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