ALL DEMOS

Spring
drag ×4

Drag the balls and let go. All four follow your drag, so the only difference is how each library springs the ball back. Motion and Anime have springs built in: you give them stiffness and damping. GSAP has a springy elastic ease, but nothing that takes stiffness and damping, so I work out the spring myself and give it the curve. CSS can't do springs at all, so it fakes one with a single bounce. Move the damping slider and watch which ones change.

010 kB · NATIVECSSOne overshoot ease, duration matched by eye
0230 kB gz · 3.13GSAPCustomEase running a solved spring curve
0320 kB gz · v11MotionReal solver, stiffness and damping passed straight through
0413 kB gz · v4Anime.jsspring() used as the easing function

Drag anywhere on the fields.Drag any ball. All four follow together.

0, 0 PX

spring.css
/* CSS doesn't do springs. This is what I used
   instead: one line, one bounce past the target.
   The duration changes to match how long the real
   spring takes to settle, but the bounce is always
   the same shape. Obviously CSS doesn't have a
   place for damping, so it doesn't apply here. */
.ball {
  transition: translate 767ms
    cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* On release, go back to 0. The ease adds the bounce. */
.ball.released {
  translate: 0px 0px;
}

Ratings

OnboardingHow fast I got a first version working.
ErgonomicsHow well the API fits the job once you know it.
IterationHow cheap it is to tweak a number and look again.
DebuggingHow easy it was to find out why it looked wrong.
RealismHow close the result is to the motion in the brief.

What I like

It's one line from an easing cheat sheet, with no maths and no build step. It looks springy enough, and it only animates translate, so it runs off the main thread, like the bounce.

What I don't

It isn't really a spring. It bounces once, in a shape I picked by eye, and there's nowhere to put stiffness or damping, so the damping slider moves the other three and leaves this one alone. Real physics means solving it in JS and pasting in a hundred numbers.

How it's built

One overshoot ease, duration matched by eye

What it computes

y(s) = 3(1−s)²s·1.56 + 3(1−s)s²·1 + s³767ms · nowhere to put k or c

Loading engines…