Jump to content
Search Community

Slowing down repeating animation until it reaches start.

shshaw test
Moderator Tag

Go to solution Solved by Carl,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Posting this for future Google searchers:

 

To slow down a repeating animation in GSAP so it seems like it's losing momentum until it reaches the end position, animate both the 'timeScale' and 'progress' properties! Thanks to zadvorsky and zachsaucier for their help.

var spin = TweenMax.to('#group',2,{
  transformOrigin: 'center center',
  rotation: 360,
  ease: 'Linear.easeNone',
  repeat: -1,
  paused: true
});

document.getElementById('finish').addEventListener('click',function(){
  var remaining = spin.timeScale() * ( spin.duration() - spin.time() ) * 3;

  TweenMax.to(spin, remaining, {
    timeScale: 0,
    ease: 'Linear.easeNone',
    onComplete: function(){ spin.pause(); }
  },0);
  
  TweenMax.to(spin, remaining, {
    progress: 1,
    ease: 'Power3.easeOut',
  },0);
  
});
 

I haven't figured out a better way to calculate how long the slow-down animation should last. "spin.timeScale() * ( spin.duration() - spin.time() ) * 3" feels right for this animation, but three is a bit of a magic number. Any ideas on how to better calculate that?

 
 

See the Pen oLBqWz?editors=0010 by shshaw (@shshaw) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the demo.

 

In addition to determining the duration the tricky part is finding an ease that will match the current velocity of the progress().

I think the best way to do this would be be to use ThrowProps as it will allow you to track() the velocity of the progress and then create a progress tween that tweens the progress() at the existing rate of change and will end at a progress(0). 

 

See if this works better for you:

http://codepen.io/GreenSock/pen/ezvzEo?editors=0010

 

ThrowPropsPlugin is available to Club GreenSock members (Shockingly and above).

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