6.4 · Motion

Springs and bounces: linear() easing

Springs and bounces as a timing function, built from points.

cubic-bezier() can’t overshoot more than once, so real springs and bounces needed JavaScript. linear() takes a list of points, each an output value and an optional position, and draws straight lines between them.

With enough points it approximates any curve, including ones that go past 1 and settle back. Generators like the linear() easing tool by Jake Archibald turn a spring into a point list.

Before
// A spring library, or:
el.animate(keyframes, {
  duration: 1000,
  easing: 'cubic-bezier(0.3, 1.5, 0.7, 1)',
  // one overshoot only
})
Now
.ball {
  transition: translate 1s linear(
    0, 0.141, 0.723 12.9%, 1.149 24.3%,
    1.163, 1.051 39.6%, 0.974 53.8%, 1
  );
}