26. Easing Functions

The math behind smooth animations and natural motion

Click a button on a well-designed website and a panel slides open. It doesn't move at constant speed — it starts slowly, accelerates, and then gently decelerates into its final position. That "feel" — the difference between mechanical and natural — comes from an easing function.

An easing function maps a linear progress value t (from 0 to 1) to an output value that controls the rate of change over time. At t=0 the animation begins; at t=1 it ends. Everything in between is shaped by the curve. Linear interpolation feels robotic. A well-chosen easing function makes motion feel alive.

The Basics: What Easing Functions Do

Every animation has a start state and an end state. The simplest interpolation is linear:

value = start + (end - start) × t

where t goes from 0 to 1 over the animation's duration. This produces constant velocity — the object moves the same amount each frame. It works, but it feels stiff.

Easing functions replace the raw t with a shaped version:

value = start + (end - start) × ease(t)

The function ease(t) still maps [0,1] → [0,1], but it changes how progress is distributed over time.

Three families of easing

Ease-in: starts slow, accelerates — like a car pulling away from a stop.
Ease-out: starts fast, decelerates — like a ball rolling to a stop.
Ease-in-out: slow start, fast middle, slow end — the most natural for UI transitions.

Linear

The baseline. No easing at all — constant velocity from start to finish.

Linear

ease(t) = t

Rate of change is constant. The derivative is always 1.

Polynomial Easing (Quad, Cubic, Quart, Quint)

The simplest easing functions are powers of t. Higher powers produce more dramatic acceleration.

Ease-In (Power curves)

Polynomial ease-in

easeInQuad(t)  = t²       — gentle acceleration
easeInCubic(t) = t³       — moderate acceleration
easeInQuart(t) = t⁴       — strong acceleration
easeInQuint(t) = t⁵       — very strong acceleration

Why does t² ease in? At t=0.1, the output is 0.01 — barely moved. At t=0.5, the output is 0.25 — still behind halfway. The motion is "back-loaded," with most movement happening in the second half.

Ease-Out (Flipped power curves)

To convert an ease-in into an ease-out, we flip the curve horizontally and vertically:

The ease-out transform

easeOut(t) = 1 - easeIn(1 - t)

easeOutQuad(t) = 1 - (1-t)² = t(2-t) easeOutCubic(t) = 1 - (1-t)³ easeOutQuart(t) = 1 - (1-t)⁴ easeOutQuint(t) = 1 - (1-t)⁵

At t=0.5, easeOutQuad returns 0.75 — already 75% of the way there. The motion is "front-loaded," with most happening in the first half.

Ease-In-Out (Combined)

Use the ease-in curve for the first half and the ease-out curve for the second half, scaled to meet in the middle:

Ease-in-out construction

easeInOutQuad(t):
  if t < 0.5:  return 2t²
  else:        return 1 - (-2t + 2)² / 2

easeInOutCubic(t): if t < 0.5: return 4t³ else: return 1 - (-2t + 2)³ / 2

The result is symmetric: slow start, fast middle, slow end. At t=0.5, the output is exactly 0.5.

Sinusoidal Easing

Instead of polynomials, use sine and cosine curves for a more organic feel:

Sine-based easing

easeInSine(t)    = 1 - cos(t × π/2)
easeOutSine(t)   = sin(t × π/2)
easeInOutSine(t) = -(cos(π × t) - 1) / 2

Sinusoidal easing is subtler than quadratic — it's the gentlest of the standard easing families. CSS's ease keyword uses a similar curve.

Exponential Easing

Exponential easing produces dramatic acceleration — the object barely moves for most of the ease-in, then explodes into motion:

Exponential easing

easeInExpo(t)    = 2^(10(t - 1))     (≈ 0 for small t, 1 at t=1)
easeOutExpo(t)   = 1 - 2^(-10t)      (fast start, asymptotic approach)
easeInOutExpo(t):
  if t < 0.5:  return 2^(20t - 10) / 2
  else:        return (2 - 2^(-20t + 10)) / 2

Circular Easing

Uses the equation of a circle for a distinctive "pull" at the start:

Circular easing

easeInCirc(t)    = 1 - √(1 - t²)
easeOutCirc(t)   = √(1 - (t-1)²)
easeInOutCirc(t):
  if t < 0.5:  return (1 - √(1 - (2t)²)) / 2
  else:        return (√(1 - (-2t + 2)²) + 1) / 2

Back Easing

The animation overshoots the target and then settles back — like pulling a slingshot:

Back easing

c1 = 1.70158    // overshoot amount (the "magic number")
c3 = c1 + 1

easeInBack(t) = c3 × t³ - c1 × t² easeOutBack(t) = 1 + c3 × (t-1)³ + c1 × (t-1)²

The constant 1.70158 produces a 10% overshoot. Increase it for more dramatic pull-back; decrease it for a subtler effect.

The ease-in version goes negative before going forward (the element pulls back before launching). The ease-out version overshoots past 1 before settling back.

Elastic Easing

Simulates an elastic spring — the animation oscillates around the target before settling:

Elastic easing

c4 = (2π) / 3

easeInElastic(t) = -2^(10t - 10) × sin((10t - 10.75) × c4) easeOutElastic(t) = 2^(-10t) × sin((10t - 0.75) × c4) + 1

The exponential term controls the decay, and the sine term creates the oscillation. The result looks like a damped spring.

Bounce Easing

Simulates a ball bouncing — sharp decelerations at each "bounce" followed by smaller rebounds:

Bounce easing (ease-out)

easeOutBounce(t):
  n1 = 7.5625
  d1 = 2.75

if t < 1/d1: return n1 × t² else if t < 2/d1: t -= 1.5/d1 return n1 × t² + 0.75 else if t < 2.5/d1: t -= 2.25/d1 return n1 × t² + 0.9375 else: t -= 2.625/d1 return n1 × t² + 0.984375

Each branch is a parabola (a bounce). The peaks decrease: 0.75, 0.9375, 0.984375 — each bounce reaches closer to 1. The constants are tuned so the bounces feel physically plausible.

Ease-in bounce is derived by flipping: easeInBounce(t) = 1 - easeOutBounce(1 - t).

Cubic Bezier: The CSS Standard

CSS transition-timing-function uses cubic Bezier curves defined by two control points, (x1, y1) and (x2, y2):

CSS cubic-bezier

cubic-bezier(x1, y1, x2, y2)

The curve starts at (0,0) and ends at (1,1). Control points (x1,y1) and (x2,y2) shape the middle.

Standard CSS keywords: ease = cubic-bezier(0.25, 0.1, 0.25, 1.0) ease-in = cubic-bezier(0.42, 0, 1.0, 1.0) ease-out = cubic-bezier(0, 0, 0.58, 1.0) ease-in-out = cubic-bezier(0.42, 0, 0.58, 1.0) linear = cubic-bezier(0, 0, 1.0, 1.0)

Cubic Bezier curves are more flexible than the fixed easing functions above — by adjusting the two control points, you can approximate any of them and create custom curves. The tradeoff: evaluating a Bezier requires solving a cubic equation (finding the t that produces a given x), which is more expensive than a simple polynomial.

Choosing the Right Easing

Context Recommended easing Why
UI panel open/close ease-out or ease-in-out Feels responsive — fast start, gentle stop
Attention-grabbing popup ease-out-back Overshoot draws the eye
Loading indicator ease-in-out-sine Gentle, looping, non-distracting
Game physics ease-out-elastic or bounce Mimics real-world spring/impact
Fade in/out ease-in-out-quad Subtle, smooth opacity change
Scroll to section ease-in-out-cubic Natural deceleration at destination

The Rule of Thumb

Ease-out for entrances (element appearing — it should arrive quickly and settle).
Ease-in for exits (element leaving — it should start slow and then disappear quickly).
Ease-in-out for transitions between two states.

Implementation Patterns

In practice, easing functions are used in an animation loop:

function animate(duration, easeFn, onUpdate):
    startTime = now()

    function frame():
        elapsed = now() - startTime
        t = clamp(elapsed / duration, 0, 1)
        value = easeFn(t)
        onUpdate(value)

        if t < 1:
            requestAnimationFrame(frame)

    requestAnimationFrame(frame)

The onUpdate callback receives the eased value (0 to 1) and maps it to whatever property you're animating — position, opacity, scale, color.

Where Easing Functions Are Used

Application How it uses easing
CSS transitions transition-timing-function applies Bezier easing to property changes
JavaScript animation libraries GSAP, Framer Motion, anime.js — all ship a library of easing functions
Game engines Tweening systems for camera movement, UI, particle effects
Data visualization D3.js uses easing for animated transitions between chart states
Mobile apps iOS and Android animation frameworks use spring and curve-based easing
Motion design After Effects, Figma — easing curves for keyframe interpolation

Key Takeaways

  • Easing functions map linear progress t ∈ [0,1] to a shaped output that controls animation feel
  • Ease-in = slow start (power of t); ease-out = slow end (flipped); ease-in-out = both
  • Polynomial (quad, cubic, quart, quint) easing is the simplest family — just powers of t
  • Sinusoidal, exponential, and circular easing offer increasingly dramatic curves
  • Back, elastic, and bounce add physical character — overshoot, spring, and impact
  • CSS uses cubic Bezier curves with two control points for flexible custom easing
  • The ease-out transform 1 - easeIn(1-t) converts any ease-in into an ease-out
  • Choose ease-out for entrances, ease-in for exits, ease-in-out for state transitions

Try It Yourself — Easing Function Explorer

Select an easing function to see its curve, formula, and a live animation preview. Compare different functions side by side to see how they feel. Drag the control points on the Bezier editor to create custom curves.

Curve

Animation


Easing functions are where math meets perception. A quadratic curve is just t², but the difference it makes to how an animation feels is enormous. The best part: the entire family is built from a single idea — reshaping linear progress with a curve — and every variant is just a different curve. Once you internalize the ease-in/ease-out/ease-in-out pattern and the 1 - f(1-t) flip trick, you can construct or modify any easing function from first principles.