Inertia Bounce

Adds a natural bounce at the end of any keyed motion.

Code

// Any property with a final keyframe
var n = 4;      // bounces
var amp = .08;  // amplitude
var freq = 2;
var decay = 4;
if(numKeys>0){
  var t = time - key(numKeys).time;
  if(t < 1){
    var v = velocityAtTime(key(numKeys).time - 0.001);
    value + v * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t);
  } else value;
} else value;
motionphysicsbounce

How to Use

Add keyframes first, then paste this on the property. Tweak `amp`, `freq`, and `decay` for harder or softer hits.