Jump to content
Search Community

Draggable Marquee effect

Akash Ranjan
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Posted

Hello Guys,

 

I was searching for a draggable marquee effect when I stumbled upon this code pen.  This is exactly what I need but I want a marquee effect applied to it which runs in a seamless loop. I tried adding it from my end but it does not work. Please help me

 

Thank You

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

Posted

 

Can you share what you've already tried? We love to see what you can come up with, that way we can see your thought process and thus better help you understand the tools!

 

 

  • Like 1
  • Solution
Posted

Ah, I see. It is always a good idea to read the code you've copied and pasted, not that you'll understand everything, but it is good to familiarise yourself with what you use. If you check the function, there is a property called paused, which is set to true. If you remove this it will just do what you want. Hope it helps and happy tweening! 

 

See the Pen LYwOydX by mvaneijgen (@mvaneijgen) on CodePen.

  • Like 2
Posted

Yes, you are correct. Although I have read the code I completely missed that part. Thank you so much for your help @mvaneijgen

 

Also, I noticed that the marquee stops after some time. Can you tell me the reason for this?

  • Like 1
Posted

Currently it plays just once, that is why it stops.

 

Before the helper loop function there are a bunch of comments all explaining what the features are of the function. Check it out you might find what you're looking for. If not post back here and let us know what you've tried.

 

If you're familiar with timelines or tweens you might already be able to guess what you can set to solve your issue. 

  • Like 1
Posted

Hi,

 

As @mvaneijgen mentions there are a few config options that you can pass to the Horizontal Loop helper, one of those is repeat:

const loop = horizontalLoop(".selector", {
  // Will repeat once after is completed the first time
  repeat: 1,
});

const loop = horizontalLoop(".selector", {
  // Will repeat indefinitely 
  repeat: -1,
});

When you pass any number bigger than 0 it will repeat that many times after the first run, if you pass -1 it will run endlessly.

 

Hopefully this clear things up

Happy Tweening!

  • 2 weeks later...
Posted

Thanks @Rodrigo,

 

The repeat function I figured out but there is one issue the click function.  Whenever I click on any of the box or the next and previous button the marquee stops and never resumes. Can you help me with that please?

Posted

Do you have an up to date demo for us? So that we can see what you're looking at.

Posted

As a quick setup I've add an onComplete callback on the next button that waits for 1 second and then .play()'s the loop again, this you'll need to add to all the addEventListener's and setup how much time you want to wait (or not) for it to start up again. Hope it helps and happy tweening! 

 

See the Pen MWNqyML?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen.

Posted

Hi,

 

I made a fork of the original demo in our collection and added an onComplete to the toIndex method on the helper function in order to restart the loop:

function toIndex(index, vars) {
  vars = vars || {};
  vars.onComplete = () => tl.paused(false);
  // ...
}

It's on line 142 of the JS panel in this demo:

See the Pen zYgJwKJ by GreenSock (@GreenSock) on CodePen.

 

Feel free to replace that for a GSAP delayed call if you want to wait for some time in order to restart the loop, something like this:

 

function toIndex(index, vars) {
  vars = vars || {};
  // Wait for 0.5 seconds before restarting the loop
  vars.onComplete = () => gsap.delayedCall(0.5, () => tl.paused(false));
  // ...
}

Hopefully this helps

Happy Tweening!

  • 2 weeks later...
Posted

Hey @Rodrigo,

 

I just noticed a bug in the above code pen. If a user drags more than once quickly or drags again before the previous drag is finished, the slider stops.

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