Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Key

Loop animation while dragging

Recommended Posts

Hello,

 

I'm trying to loop a "shake" animation of my drop-area as long as my droppable item is dragged. 

The animation should start 2sec after an item is dragged and should be repeated every 2 seconds.

 

I found a few pens/topics but none of them could make it works.

 

As you can see, I tried using onPress/Release, but it's still not working, and I have a shake animation after page loaded, which I don't want.

 

Is there a way to do that ?

 

Quentin

See the Pen pYJKqg?editors=1010 by anon (@anon) on CodePen

Link to comment
Share on other sites

Welcome to the forum.

 

You'll need to use TweenMax if you want to use the repeat() and repeatDelay() methods. From the docs:

TweenMax extends TweenLite, adding many useful (but non-essential) features like repeat(), repeatDelay(), yoyo(), and more.

https://greensock.com/docs/TweenMax

 

Here's a fork of your pen.

See the Pen moJGEE by PointC (@PointC) on CodePen

Hopefully that helps. Happy tweening.

:)

 

  • Like 2
Link to comment
Share on other sites

Awesome ! Thank you @PointC

 

Just another small thing, is there a way to pause the "shakeIt" animation before it starts to avoid the rotate -20 of my drop-area ?

 

Quentin

Link to comment
Share on other sites

Sure, you can set immediateRender to false. I've updated the pen.

 

See the Pen moJGEE by PointC (@PointC) on CodePen

Happy tweening.

 

  • Like 2
Link to comment
Share on other sites

That's perfect, thank you !

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

×