Jump to content
GreenSock

Karen

Button elastic animation

Recommended Posts

Hello, need some help, want to create the animation like here

 

https://tympanus.net/Development/ElasticSVGElements/button.html

 

Now my progress is this

 

 

My main issue is to pause the animation when user clicks and holds the mouse, i can't get it work, could you please give me advice?

See the Pen VwZJEgW by enovathemes (@enovathemes) on CodePen

Link to comment
Share on other sites

@Karen, you can add timer after the mouse is clicked. And this timer will stop timeline animation whenever you want. For example, inside 'mousedown touchstart' event listener add setTimout after your tl.start() method, like this:

setTimeout(() => {
  tl.pause();
}, 400);

400 it is your animation timing, which is 0.4.

 

Also, I recommend you to replace tl.reverse() with a new morphSVG animation which will morph into the original state. Because a simple reverse looks  unnatural.

Link to comment
Share on other sites

Hey Karen and welcome to the forums! Thanks for being a Business Green member. We couldn't do what we do without people like you.

 

I would actually recommend using two separate tweens in this case, as Aleksei suggests. That way you have full control over the way each is easing. You could set it up like so:

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

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