Travis Michael Heller Travis Michael Heller - 1 year ago 67
jQuery Question

How to make a greensock animation reverse but faster than original animation?

I have an animation that i am using Greensock for.
When this animation is complete and when the user clicks on a button the animation will play in reverse. The issue i have is that i want the animation to play in reverse 3 times faster than when it was originally played.
I am stumped on how to do this.

The current code i have works fine, i just need it to animate in reverse faster.
Any help is greatly appreciated, thank you.
Current code:

var tl = new TimelineMax();
var page4 = function(){
tl.staggerFrom("input", 0.5, {
}, 0.2);
tl.staggerFrom("label", 0.5, {
}, 0.2);
tl.staggerFrom("#submit", 0.5, {
}, 0.2);

$('#submit').on('click', function(e){
}, 3000 );

function contact(){
var msg = '<p>Thank you for your submission! Please give us 1 business day to reply back.</p>';

Answer Source

It should be as simple as setting the timeScale() to 3 (meaning it'll play 3x faster than normal):


And remember, you can chain things, so you could reverse() it at the same time:


And then when you need to go forward again:;

It's all in the docs:

I also noticed that you're using a setTimeout() to call contact() after 3 seconds. That's fine, but if you want to have it called as soon as the timeline finishes (in either direction), you can set onComplete:contact and onReverseComplete:contact. Or there's also a TweenLite.delayedCall() that'll act much like setTimeout() but always remain perfectly synchronized with the whole GSAP engine and likely be more performant.

Happy tweening!