Expression Library

Keyframe Overshoot

Author: Dan Ebberts

Keyframe overshoot applies spring or pendulum physics to a keyframed property. Not to be confused with Drop Bounce (which follows the physics of an object that bounces off of a surface), in its springiness Keyframe Overshoot is more similar to Inertial Bounce — which apparently evolved out of it. 

As Dan Ebberts points out in the blog post linked to below, Keyframe Overshoot is “property agnostic” and should work for any layer property.

Code Sample

Hover over the code and click the copy button.

				
					freq = 2;
decay = 8;

n = 0;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (key(n).time > time) n--;
}
if (n > 0){
  t = time - key(n).time;
  amp = velocityAtTime(key(n).time - .001);
  w = freq*Math.PI*2;
  value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
  value
				
			

Other Notes

This expression uses the velocity at the incoming keyframe to determine the overshoot amplitude. Easing will negate the effect if the eased keyframe is kept at zero on the speed graph. If used with easing, adjust the speed of the eased keyframe to adjust the amplitude.