Skip to content

Slow in & slow out

Easing: speed up and slow down instead of moving at constant speed.

Edit this page

Real objects speed up out of a pose (slow out) and slow down into the next one (slow in). Together they’re called easing. Animators check it with a spacing chart, one mark per frame: marks bunched together mean slow, marks spread apart mean fast. Even spacing looks mechanical.

Now showing: Easing spacing chartOpen the Easing spacing chart demo on its own page (opens in a new tab)
Show the demo's source

The complete page: it loads toon.css and toon.js, plus demo-theme.js (theme colors), demo-runtime.js (gives the demo its own clock) and, for the characters, cast.js.

<!doctype html>
<html lang="en" data-style="saturday">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>06 · Slow in &amp; slow out — toon</title>
<link rel="stylesheet" href="../src/toon.css">
<link rel="stylesheet" href="demo.css">
<style>
body { font-size: 15px; line-height: 1.5; max-width: var(--demo-max-width); margin: 2rem auto; padding: 0 1rem; }
canvas { display: block; width: 100%; height: 360px; }
</style>
</head>
<body>
<h1>Slow in &amp; slow out</h1>
<p>Objects need time to accelerate and to slow down. The ghost dots are an animator's <i>spacing chart</i>:
one dot per frame. Where the dots bunch up, the ball is moving slowly; where they spread out, it's fast. Evenly spaced dots look mechanical.</p>
<canvas id="c" role="img" aria-label="Balls slide across the canvas with different easings. Faint dots mark each frame: they bunch up where a ball moves slowly and spread out where it moves fast."></canvas>
<script src="../src/toon.js"></script>
<script src="demo-theme.js"></script>
<script src="demo-runtime.js"></script>
<script>
ToonDemos.register('06-slow-in-slow-out', (document, Toon, DemoTheme) => {
const T = DemoTheme; // design tokens, live (see demo-theme.js)
const { createStage, ticker, tween, ease } = Toon;
const stage = createStage(document.getElementById('c'));
const { ctx } = stage;
const lanes = [
['ease.linear — mechanical', ease.linear],
['ease.inQuad — slow out of the first pose', ease.inQuad],
['ease.outQuad — slow into the last pose', ease.outQuad],
['ease.inOutCubic — slow out + slow in', ease.inOutCubic],
['ease.cubicBezier(.7, 0, .2, 1) — custom', ease.cubicBezier(0.7, 0, 0.2, 1)],
['ease.outBack — slow in with overshoot', ease.outBack],
];
let p = 0;
tween({ duration: 1600, ease: ease.linear, repeat: Infinity, yoyo: true, onUpdate: v => (p = v) });
stage.loop(() => {
const x0 = 30, x1 = stage.width - 40, gap = stage.height / lanes.length;
stage.clear();
lanes.forEach(([label, fn], i) => {
const y = gap * i + gap * 0.62;
ctx.fillStyle = T.muted; ctx.font = '12px ui-monospace, monospace'; ctx.fillText(label, x0, y - 18);
ctx.strokeStyle = T.faint; ctx.beginPath(); ctx.moveTo(x0, y); ctx.lineTo(x1, y); ctx.stroke();
for (let f = 0; f <= 16; f++) { // spacing chart: one ghost per frame
ctx.fillStyle = T.alpha(T.secondary, .45);
ctx.beginPath(); ctx.arc(Toon.lerp(x0, x1, fn(f / 16)), y, 3, 0, 7); ctx.fill();
}
ctx.fillStyle = T.primary;
ctx.beginPath(); ctx.arc(Toon.lerp(x0, x1, fn(p)), y, 9, 0, 7); ctx.fill();
});
});
});
</script>
</body>
</html>

toon.css has no easing preset class. Its easing comes as custom properties, so put one in your own transition or animation. This snippet runs as-is:

<link rel="stylesheet" href="toon.css">
<div class="slide" style="width:32px; height:32px;
border-radius:50%; background:var(--toon-color);
transition:translate 800ms var(--toon-ease-in-out)"></div>
<button id="move">Move</button>
<script>
const balls = document.querySelectorAll('.slide');
// Reduced motion: jump to the new spot instead of sliding.
const still = matchMedia('(prefers-reduced-motion: reduce)');
let across = false;
document.querySelector('#move').onclick = () => {
across = !across;
for (const ball of balls) {
ball.style.transitionDuration = still.matches ? '0s' : '';
ball.style.translate = across ? '200px 0' : '0 0';
}
};
</script>

Below, the snippet’s ball is the bottom one. The other two make the same 200px move with linear and --toon-ease-out:

Now showing: CSS easingOpen the CSS easing demo on its own page (opens in a new tab)

--toon-ease-in-out is a cubic-bezier() curve that starts slowly, speeds up in the middle and slows into the end. The linear ball covers the same distance in the same 800 ms, but starts and stops dead.

This chart runs as-is. Give each tween an ease to set its spacing. Every easing on Toon.ease is also a plain function from progress (0 to 1) to eased progress, which is how the marks are drawn.

  • Mind the names. “Slow in” is an ease-out curve, because it slows into the end pose. Use --toon-ease-out for things arriving and --toon-ease-in for things leaving.
  • Ease in and out between two rest poses. A panel that slides from one place to another needs both ends soft, so use --toon-ease-in-out. To match a CSS curve exactly in Canvas, pass its four numbers to ease.cubicBezier().
  • Use quadratics for gravity. Anything thrown or falling should use quadratic easing: --toon-ease-rise and --toon-ease-fall in CSS, and outQuad and inQuad in Canvas.
  • Use linear only on purpose, for machines, scrolling backgrounds, or one axis of an arc.

For every option, see the Canvas easing functions and the CSS easing variables.