After Effects Inertial Bounce Spring Expression

This article explains the concept of inertial bounce in motion design and provides a ready-to-use spring expression for Adobe After Effects. You will learn the physics behind the effect, how the expression automates natural overshoot animations without manual keyframing, how to apply the code to your layers, and how to customize the variables to fit your project's aesthetic.

What is Inertial Bounce?

Inertial bounce, often referred to as overshoot or spring motion, is an animation technique that simulates real-world physics. When an object in the physical world moves rapidly to a stop, momentum carries it slightly past its resting point before tension pulls it back, creating a decaying oscillation until it comes to a complete rest.

In digital motion graphics, inertial bounce prevents animations from stopping abruptly or looking robotic. While you can achieve this effect using manual graph editor adjustments, doing so requires dense keyframing that is difficult to edit later. An After Effects expression automates this calculation based on the velocity of your existing keyframes.

The Inertial Bounce Expression Code

The following expression evaluates the velocity of a property at the final keyframe and applies a decaying sine wave to create an organic spring reaction:

// Inertial Bounce / Overshoot Expression
n = 0;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (key(n).time > time){
    n--;
  }
}

if (n == 0){
  t = 0;
} else {
  t = time - key(n).time;
}

if (n > 0 && t < 1){
  v = velocityAtTime(key(n).time - ((thisComp.frameDuration) / 10));
  amp = 0.05;
  freq = 4.0;
  decay = 8.0;
  value + v * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t);
} else {
  value;
}

How to Apply the Expression in After Effects

  1. Set Keyframes: Create at least two keyframes for any transform property (such as Position, Scale, or Rotation) to define the initial movement.
  2. Open the Expression Field: Hold Alt (Windows) or Option (macOS) and click the stopwatch icon next to the animated property.
  3. Paste the Code: Paste the script into the text area that appears in the Timeline panel.
  4. Click Away: Click outside the text box to commit the expression.
  5. Adjust Keyframe Spacing: Preview your animation. If the movement is too slow, the bounce will be subtle; if the movement between keyframes is fast, the spring effect will be more pronounced.

Customizing the Spring Variables

To change the behavior of the bounce, modify the three core parameters within the expression:

  • amp (Amplitude): Controls the intensity or height of the bounce. Increasing this value makes the overshoot push further past the final keyframe value. Typical values range from 0.02 to 0.1.
  • freq (Frequency): Dictates how many times the layer oscillates back and forth per second. Higher values make the layer vibrate or snap rapidly, while lower values produce a sluggish, loose swing. Typical values range from 2.0 to 6.0.
  • decay (Decay): Determines how quickly the oscillation fades to zero. A higher decay stops the bounce almost immediately, while a low decay lets the spring wobble for an extended period. Typical values range from 5.0 to 12.0.