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.
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 & 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 & 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>Slow in & slow out in CSS
Section titled “Slow in & slow out in CSS”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:
Press Move to send the balls across and back.
--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.
Slow in & slow out in Canvas
Section titled “Slow in & slow out in Canvas”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.
<script src="toon.js"></script><canvas style="width:100%; height:180px" role="img" aria-label="Two balls slide back and forth. Marks under the top ball are evenly spaced; marks under the eased ball bunch up at both ends, where it moves slowly"></canvas>
<script>const { createStage, tween, ease, lerp } = Toon;const stage = createStage(document.querySelector('canvas'));// One lane per easing. Each tween moves its ball from 0 to 1.const lanes = [ { label: 'ease.linear', ease: ease.linear, p: 0 }, { label: 'ease.inOutCubic', ease: ease.inOutCubic, p: 0 },];for (const lane of lanes) { tween({ duration: 1200, ease: lane.ease, repeat: Infinity, yoyo: true, onUpdate: (v) => (lane.p = v) });}5 collapsed lines
// Reduced motion: freeze the clock. The marks still show// where each ball is slow and where it is fast.if (matchMedia('(prefers-reduced-motion: reduce)').matches) { Toon.ticker.timeScale = 0;}
stage.loop(() => { const ctx = stage.ctx, x0 = 24, x1 = stage.width - 24;4 collapsed lines
// Colors from the page: --toon-color for the ball, text for ink. const fill = getComputedStyle(document.documentElement) .getPropertyValue('--toon-color').trim() || '#ff6b4a'; const ink = getComputedStyle(document.body).color; stage.clear(); ctx.font = '12px ui-monospace, monospace'; lanes.forEach((lane, i) => { const y = 64 + i * 80; ctx.fillStyle = ink; ctx.fillText(lane.label, x0, y - 30); // Spacing chart: where the ball is on each of 16 frames. ctx.globalAlpha = 0.45; for (let f = 0; f <= 16; f++) { const x = lerp(x0, x1, lane.ease(f / 16)); ctx.fillRect(x - 1, y + 16, 2, 10); } ctx.globalAlpha = 1; ctx.beginPath(); ctx.arc(lerp(x0, x1, lane.p), y, 12, 0, Math.PI * 2); ctx.fillStyle = fill; ctx.fill(); ctx.lineWidth = 2.5; ctx.strokeStyle = ink; ctx.stroke(); });});</script>Slow in & slow out: tuning tips
Section titled “Slow in & slow out: tuning tips”- Mind the names. “Slow in” is an ease-out curve, because it slows into the end pose. Use
--toon-ease-outfor things arriving and--toon-ease-infor 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 toease.cubicBezier(). - Use quadratics for gravity. Anything thrown or falling should use quadratic easing:
--toon-ease-riseand--toon-ease-fallin CSS, andoutQuadandinQuadin 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.