Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

feat: move Dissolve Transition to the guided-steps page

matin5d28a25b79e2
diff --git a/animations/03-page-transitions/dissolve/README.md b/animations/03-page-transitions/dissolve/README.md
index 215c1816..eb7e6973 100644
--- a/animations/03-page-transitions/dissolve/README.md
+++ b/animations/03-page-transitions/dissolve/README.md
@@ -1,7 +1,7 @@
# Dissolve
## What it is
-A dissolve is a non-uniform fade: the screen is divided into a grid of tiles, and each tile fades at a slightly different time according to a delay pattern. Because regions disappear out of sync, the change reads as the old scene dissolving into grain rather than the whole image fading at once. The delay pattern — random, diagonal, or radial — determines the texture of the wipe.
+A dissolve breaks a page change into a grid of tiles. Each tile fades in over the old page at a slightly different moment, so the old page seems to break up into grain or blocks rather than fading evenly. The order of the tiles — random, a diagonal sweep or rings from the middle — gives the dissolve its texture.
## When to use it
- Transitions that want more texture than a plain crossfade but less drama than a slide or zoom
@@ -25,10 +25,10 @@ function getDelays(n, style) {
return (r + c) / (2 * (n - 1));
});
}
- // radial: distance from the grid center
+ // radial: tile-centre distance, normalised so the corners land at 1
return Array.from({length: total}, (_, i) => {
- const r = Math.floor(i / n) - n / 2, c = i % n - n / 2;
- return Math.sqrt(r * r + c * c) / Math.sqrt(2) * n / 2 / (n * 0.8);
+ const r = Math.floor(i / n) - (n - 1) / 2, c = i % n - (n - 1) / 2;
+ return Math.sqrt(r * r + c * c) / (Math.SQRT2 * (n - 1) / 2);
});
}
```
@@ -38,11 +38,10 @@ Each tile's inline style bakes the normalized delay into a real transition: `tra
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
-| Dissolve style | random | `random` = grain, `diagonal` = sweep, `radial` = wipe from center out |
-| Granularity | 8×8 | Tile count. Coarse reads as blocks; fine (16×16) approaches a smooth fade |
-| Duration | 800ms | Total wipe time; the swap fires at ~60% through, under the tiles |
-| Dissolve in + out | off | Fades tiles back out over the new page for a symmetric transition |
-| Show tile mask | off | Outlines each tile in red to expose the grid structure |
+| Pattern | Random | The order the tiles appear in: random looks like grain, diagonal sweeps from one corner, and from the middle spreads out in rings |
+| Tile size | Medium | How big the tiles are: small is a 16 by 16 grid, medium 8 by 8 and large 4 by 4; small tiles come close to a smooth fade |
+| Speed | Normal | How long the tiles take: slow is 1300ms, normal 800ms and fast 500ms; the page swaps at 60% of it, under the tiles |
+| Dissolves both ways | off | Also fades the tiles away in the same pattern to reveal the new page, instead of removing them at once |
## Production notes
- **Random needs a stable order.** Shuffling the tile order once and mapping each tile to its rank keeps the pattern coherent; re-randomizing per frame would flicker. This demo shuffles a single order array and reuses it.
@@ -51,7 +50,7 @@ Each tile's inline style bakes the normalized delay into a real transition: `tra
- **Library equivalents.** The View Transitions API can dissolve with a masked `::view-transition-old` but does not offer per-tile stagger out of the box — a generated mask image is the native route. GSAP's `stagger` with a `grid` and `from: 'random'` reproduces this directly. Shader-based dissolves sample a noise texture against a rising threshold, which is the same idea at pixel granularity.
## See also
-- [Crossfade](../crossfade/) — the uniform fade this breaks into staggered tiles
-- [Flash / Light Leak](../flash-transition/) — another overlay that hides the swap
-- [Blur Transition](../blur-transition/) — a softer non-tiled way to mask the change
-- [Slide Transition](../slide-transition/) — a directional wipe without the tile texture
+- [Crossfade Transition](../crossfade/) — an even fade with no tiles
+- [Flash / Light Leak Transition](../flash-transition/) — a burst of light hides the change
+- [Blur Transition](../blur-transition/) — a blur hides the change
+- [Slide Transition](../slide-transition/) — pages move instead of dissolving
diff --git a/animations/03-page-transitions/dissolve/index.html b/animations/03-page-transitions/dissolve/index.html
index 1d579671..f6c596e0 100644
--- a/animations/03-page-transitions/dissolve/index.html
+++ b/animations/03-page-transitions/dissolve/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dissolve Transition — Animation Handbook</title>
- <meta name="description" content="Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.">
+ <meta name="description" content="The page breaks into tiles that give way to the next. Best for photo galleries.">
<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/animations/03-page-transitions/dissolve/">
<link rel="icon" type="image/png" sizes="96x96" href="../../../favicon.png">
<link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
@@ -12,139 +12,211 @@
<meta property="og:type" content="article">
<meta property="og:site_name" content="Animation Handbook">
<meta property="og:title" content="Dissolve Transition — Animation Handbook">
- <meta property="og:description" content="Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.">
+ <meta property="og:description" content="The page breaks into tiles that give way to the next. Best for photo galleries.">
<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/animations/03-page-transitions/dissolve/">
<meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Dissolve Transition — Animation Handbook">
- <meta name="twitter:description" content="Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.">
+ <meta name="twitter:description" content="The page breaks into tiles that give way to the next. Best for photo galleries.">
<meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Dissolve Transition", "name": "Dissolve Transition", "description": "Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/03-page-transitions/dissolve/", "inLanguage": "en", "articleSection": "Page Transitions", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Page Transitions, Dissolve Transition"}</script>
+ <script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Dissolve Transition", "name": "Dissolve Transition", "description": "The page breaks into tiles that give way to the next. Best for photo galleries.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/03-page-transitions/dissolve/", "inLanguage": "en", "articleSection": "Page Transitions", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Page Transitions, Dissolve Transition"}</script>
<style>
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}
- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}
- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}
- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#b98cff;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px}
+ :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#b98cff;--ui-text:#f4f4f2;--ui-muted:#8a8a92}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
- body{background:var(--bg);color:var(--ui-text);font-family:var(--mono);-webkit-font-smoothing:antialiased;padding:clamp(12px,3vw,24px)}
- header{margin-bottom:20px}
- header h1{font-family:var(--disp);font-weight:700;font-size:clamp(16px,2.2vw,22px);letter-spacing:-.01em}
- header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
- .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
- .stage{flex:1;min-width:0;height:var(--stage-h);border:1px solid var(--ui-border);border-radius:8px;background:var(--bg);overflow:hidden;display:flex;flex-direction:column}
+ .stage{display:flex;flex-direction:column;overflow:hidden;background:var(--bg);color:var(--ui-text)}
.mini-nav{display:flex;gap:6px;padding:10px 12px;background:var(--ui-bg);border-bottom:1px solid var(--ui-border);flex-shrink:0}
- .nav-btn{background:none;border:1px solid var(--ui-border);color:var(--ui-muted);font-family:monospace;font-size:10px;padding:6px 14px;border-radius:4px;cursor:pointer;min-height:36px}
+ .nav-btn{background:none;border:1px solid var(--ui-border);color:var(--ui-muted);font:inherit;font-size:13px;padding:0 12px;border-radius:4px;cursor:pointer;min-height:44px}
.nav-btn.active{border-color:var(--ui-accent);color:var(--ui-accent)}
+ @media(hover:hover){.nav-btn:hover{border-color:var(--ui-accent)}}
.page-area{flex:1;position:relative;overflow:hidden}
- .page{position:absolute;inset:0;pointer-events:none}
- .page.active{pointer-events:auto}
+ .page{position:absolute;inset:0;opacity:0;pointer-events:none}
+ .page.active{opacity:1;pointer-events:auto}
.pc{display:flex;flex-direction:column;justify-content:center;height:100%;padding:clamp(20px,4vw,40px);gap:12px}
- .pe{font-size:10px;text-transform:uppercase;letter-spacing:3px;opacity:.4}
+ .pe{font-size:10px;text-transform:uppercase;letter-spacing:3px;opacity:.6}
.ph{font-size:clamp(22px,3.5vw,36px);font-weight:bold;line-height:1.15}
.pp{font-size:12px;opacity:.6;line-height:1.65;max-width:320px}
.pgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:4px}
.gi{background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.1);border-radius:6px;padding:18px 12px;font-size:11px}
.pstat{display:flex;gap:20px;margin-top:4px}
.pstat b{display:block;font-size:clamp(18px,2.5vw,24px);color:var(--ui-accent)}
- .pstat span{font-size:9px;opacity:.4;text-transform:uppercase;letter-spacing:1px}
+ .pstat span{font-size:9px;opacity:.6;text-transform:uppercase;letter-spacing:1px}
/* Dissolve tile overlay */
#dissolve-overlay{position:absolute;inset:0;display:grid;z-index:10;pointer-events:none}
.dtile{background:var(--tile-bg,#060a10);opacity:0}
- aside{width:clamp(200px,22vw,240px);flex-shrink:0;background:var(--ui-bg);border:1px solid var(--ui-border);border-radius:8px;padding:16px;display:flex;flex-direction:column;gap:10px}
- .note{font-size:10px;color:var(--ui-muted);line-height:1.6;border-left:2px solid var(--ui-accent);padding-left:8px}
- .lbl{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
- .kv{display:flex;justify-content:space-between;font-size:10px;color:var(--ui-muted)}
- .kv .v{color:var(--ui-text)}
- .div{height:1px;background:var(--ui-border)}
- .sr{display:flex;align-items:center;gap:6px;font-size:10px}
- .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:44px}
- .sv{width:38px;text-align:right;color:var(--ui-text)}
- select{background:var(--ui-bg);border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:8px 6px;border-radius:4px;width:100%;min-height:44px}
- .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer;min-height:44px}
- .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
- .log{display:flex;flex-direction:column;gap:2px}
- .log-row{font-size:9px;color:var(--ui-muted)}
- button.rst{background:transparent;border:1px solid var(--ui-border);color:var(--ui-text);font-family:monospace;font-size:10px;padding:14px 8px;border-radius:4px;cursor:pointer;width:100%}
- @media(hover:hover){button.rst:hover{border-color:var(--ui-accent);color:var(--ui-accent)}.nav-btn:hover{border-color:var(--ui-accent)}}
- @media(max-width:600px){.layout{flex-direction:column;align-items:stretch}.stage{flex:none;width:100%}aside{width:100%}.nav-btn,button.rst{min-height:44px}:root{--stage-h:480px}}
+ /* Short windows leave the page area under 220px: tighter spacing keeps the tallest page inside it with room to spare */
+ @media(max-height:640px){.pc{gap:8px}.gi{padding:12px}}
@media(prefers-reduced-motion:reduce){.page{transition:opacity 300ms linear}.dtile{transition:none!important}}
</style>
-<style id="ah-inject">
-:root{--ah-bg:rgba(17,17,20,.82);--ah-line:rgba(255,255,255,.1);--ah-ink:#f4f4f2;--ah-muted:#9a9aa2;--ah-accent:#6ea8ff}
-body{padding-top:46px}
-.ah-bar{position:fixed;top:0;left:0;right:0;height:46px;z-index:2147483000;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 clamp(10px,3vw,18px);background:var(--ah-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--ah-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;box-sizing:border-box}
-.ah-bar a,.ah-bar button{color:var(--ah-muted);text-decoration:none;background:none;border:0;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 7px;border-radius:6px;transition:color .18s,background .18s;white-space:nowrap}
-.ah-bar a:hover,.ah-bar button:hover{color:var(--ah-ink)}
-.ah-home{color:var(--ah-ink);font-weight:600}
-.ah-actions{display:flex;align-items:center;gap:2px}
-.ah-sep{width:1px;height:16px;background:var(--ah-line);margin:0 4px}
-.ah-copied{color:var(--ah-accent)!important}
-@media(max-width:600px){.ah-bar .ah-hideSm{display:none}}
-@media print{.ah-bar{display:none}body{padding-top:0}}
-</style>
+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=4">
+ <script src="../../../assets/js/demo-page.js?v=4" defer></script>
</head>
-<body>
-<div class="ah-bar" role="navigation" aria-label="Animation Handbook"><a class="ah-home" href="../../../">← Animation Handbook</a><span class="ah-actions"><a class="ah-hideSm" href="../portal-zoom/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../flip-technique/" rel="next" title="Next">Next ›</a><span class="ah-sep ah-hideSm"></span><button type="button" id="ah-copy" class="ah-hideSm">Copy source</button><a class="ah-hideSm" href="https://github.com/matinmonshizadeh/animation-handbook/blob/main/animations/03-page-transitions/dissolve/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>
-<header>
- <h1>Dissolve Transition</h1>
- <p>Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.</p>
-</header>
-<div class="layout">
- <div class="stage">
- <nav class="mini-nav" id="nav"></nav>
- <div class="page-area" id="page-area">
- <div id="dissolve-overlay"></div>
+<body class="hb" data-hb-kind="do" data-hb-autoplay>
+<nav class="hb-bar" aria-label="Animation Handbook">
+ <a class="hb-home" href="../../../"><svg class="hb-mark" viewBox="0 0 32 32" aria-hidden="true"><g class="g"><circle cx="11.16" cy="20.84" r="6.1"/><circle cx="15.12" cy="16.88" r="6.1"/><circle cx="18.51" cy="13.49" r="6.1"/></g><circle class="b" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>
+ <span class="hb-pager"><a href="../portal-zoom/" rel="prev" aria-label="Previous: Portal / Tunnel Zoom"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg><span><span class="hb-dir">Previous: </span>Portal / Tunnel Zoom</span></a><a href="../flip-technique/" rel="next" aria-label="Next: FLIP Technique"><span><span class="hb-dir">Next: </span>FLIP Technique</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>
+</nav>
+<main class="hb-page">
+ <header class="hb-head">
+ <p class="hb-cat">03.11 · Page Transitions</p>
+ <h1>Dissolve Transition</h1>
+ <p class="hb-lede">The page breaks into tiles that give way to the next. Best for photo galleries.</p>
+ </header>
+
+ <section class="hb-step hb-watch" aria-labelledby="hb-watch-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">1</span>
+ <div><h2 id="hb-watch-title">Click it</h2><p>Click Work or About at the top of the box, or press Show me.</p></div>
+ </div>
+ <div class="stage">
+ <nav class="mini-nav" id="nav" aria-label="Demo pages"></nav>
+ <div class="page-area" id="page-area">
+ <div id="dissolve-overlay" aria-hidden="true"></div>
+ </div>
+ </div>
+ <div class="hb-player">
+ <button class="hb-play" type="button" id="btn-demo" data-hb-demo><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>Show me</button>
+ <button class="hb-play" type="button" id="btn-reset" data-hb-reset><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>Reset</button>
+ <label class="hb-toggle"><input class="hb-switch" type="checkbox" role="switch" id="slow-tog" data-hb-slowmo autocomplete="off"><span>Slow motion</span></label>
+ </div>
+ </section>
+
+ <section class="hb-step hb-try" aria-labelledby="hb-try-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">2</span>
+ <div><h2 id="hb-try-title">Try it</h2><p>Change a setting, then try it again or press Show me.</p></div>
+ </div>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="pattern-lbl">Pattern</p>
+ <div class="seg" id="pattern-seg" role="group" aria-labelledby="pattern-lbl">
+ <button type="button" data-pattern="random" class="on" aria-pressed="true">Random</button>
+ <button type="button" data-pattern="diagonal" aria-pressed="false">Diagonal</button>
+ <button type="button" data-pattern="radial" aria-pressed="false">From the middle</button>
+ </div>
+ <p class="hb-hint">The order in which the tiles appear.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="size-lbl">Tile size</p>
+ <div class="seg" id="size-seg" role="group" aria-labelledby="size-lbl">
+ <button type="button" data-tiles="16" aria-pressed="false">Small</button>
+ <button type="button" data-tiles="8" class="on" aria-pressed="true">Medium</button>
+ <button type="button" data-tiles="4" aria-pressed="false">Large</button>
+ </div>
+ <p class="hb-hint">Small tiles look like grain; large ones like blocks.</p>
+ </div>
+ <div class="hb-setting">
+ <p class="hb-setting-name" id="speed-lbl">Speed</p>
+ <div class="seg" id="speed-seg" role="group" aria-labelledby="speed-lbl">
+ <button type="button" data-ms="1300" aria-pressed="false">Slow</button>
+ <button type="button" data-ms="800" class="on" aria-pressed="true">Normal</button>
+ <button type="button" data-ms="500" aria-pressed="false">Fast</button>
+ </div>
+ <p class="hb-hint">How long the tiles take to cover the page.</p>
+ </div>
+ </div>
+ <details class="hb-options">
+ <summary><span class="hb-more-label">More options</span><span class="hb-less">Fewer options</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></summary>
+ <div class="hb-settings">
+ <div class="hb-setting">
+ <label class="hb-switch-row"><span>Dissolves both ways</span><input class="hb-switch" type="checkbox" role="switch" id="bi-tog" autocomplete="off"></label>
+ <p class="hb-hint">The tiles also fade away to reveal the new page.</p>
+ </div>
+ </div>
+ </details>
+ </section>
+
+ <section class="hb-step hb-prompt-step" aria-labelledby="hb-prompt-title">
+ <div class="hb-step-head">
+ <span class="hb-num" aria-hidden="true">3</span>
+ <div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>
+ </div>
+ <div class="hb-card">
+ <p class="hb-prompt">Add a dissolve transition to [the pages or images you want to switch between]. Lay a grid of tiles over the old page and fade each tile in at a slightly different moment, following a pattern such as random, a diagonal sweep or rings from the middle, so the old page breaks up instead of fading evenly. Swap the page while the tiles cover it, then remove the tiles, or fade them away in the same pattern to reveal the new page. Give each tile its own delay and let the browser run the fades. If the visitor has reduced motion turned on, use a short, plain fade instead. Match the settings listed below.</p>
+ <div class="hb-chips-box" hidden>
+ <p class="hb-chips-title">Your settings</p>
+ <ul class="hb-chips"></ul>
+ </div>
+ <div class="hb-copy-row">
+ <button class="hb-copy" type="button"><svg class="hb-ic hb-i-copy" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><svg class="hb-ic hb-i-done" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span class="hb-copy-label" aria-live="polite">Copy prompt</span></button>
+ <p class="hb-hint">Replace the words in brackets with your own element. Your settings are added at the end.</p>
+ </div>
</div>
- </div>
- <aside>
- <p class="note">Dissolve is a non-uniform fade. Random regions disappear at different times based on a noise pattern. This demo uses CSS transition-delay per tile for a lightweight implementation.</p>
- <div class="lbl">State</div>
- <div class="kv"><span>Page</span><span class="v" id="cur-page">Home</span></div>
- <div class="div"></div>
- <div class="lbl">Dissolve style</div>
- <select id="style-sel">
- <option value="random" selected>Pixel noise (random)</option>
- <option value="diagonal">Diagonal sweep</option>
- <option value="radial">Radial wipe</option>
- </select>
- <div><div class="lbl" id="gran-lbl">Granularity (tiles)</div>
- <div class="sr"><input type="range" id="gran-sl" aria-labelledby="gran-lbl" min="4" max="16" value="8" step="2"><span class="sv" id="gran-v">8×8</span></div>
+ </section>
+
+ <section class="hb-about" aria-labelledby="hb-what-title">
+ <div class="hb-what">
+ <h2 id="hb-what-title">What it is</h2>
+ <div class="hb-what-text"><p>The full explanation is in <a href="README.md">README.md</a>.</p></div>
</div>
- <div><div class="lbl" id="dur-lbl">Duration</div>
- <div class="sr"><input type="range" id="dur-sl" aria-labelledby="dur-lbl" min="200" max="2000" value="800" step="50"><span class="sv" id="dur-v">800ms</span></div>
+ <div class="hb-fit">
+ <h2>Good for</h2>
+ <ul class="hb-tags hb-good"><li>Photo galleries</li><li>Slideshows</li><li>Retro and game sites</li></ul>
+ <h3>Avoid on</h3>
+ <ul class="hb-tags hb-avoid"><li>Everyday navigation</li></ul>
</div>
- <label class="tog" for="bi-tog"><input type="checkbox" id="bi-tog"><span>Dissolve in + out (both stages)</span></label>
- <label class="tog" for="mask-tog"><input type="checkbox" id="mask-tog"><span>Show tile mask</span></label>
- <div class="div"></div>
- <div class="lbl">History</div>
- <div class="log" id="trans-log"></div>
- <div class="div"></div>
- <button class="rst" id="rst-btn">← Return to Home</button>
- </aside>
-</div>
+ </section>
+
+ <section class="hb-related" aria-labelledby="hb-related-title" hidden>
+ <h2 id="hb-related-title">Similar animations</h2>
+ <div class="hb-rel-list"></div>
+ </section>
+</main>
+<footer class="hb-foot"><span>Animation Handbook</span><a href="#top">Back to top ↑</a></footer>
<script>
const PAGES=[
- {name:'Home',bg:'linear-gradient(135deg,#0d1a2e,#192640)',html:`<div class="pc"><div class="pe">Creative Studio</div><h2 class="ph">Design without compromise.</h2><p class="pp">We craft digital products that earn attention and keep it.</p></div>`},
- {name:'Work',bg:'linear-gradient(135deg,#0d1f15,#152e1e)',html:`<div class="pc"><div class="pe">Selected Work</div><h2 class="ph">The Portfolio</h2><div class="pgrid">${['Atlas','Orbit','Prism','Lumen','Frame','Echo'].map(n=>`<div class="gi">${n}</div>`).join('')}</div></div>`},
- {name:'About',bg:'linear-gradient(135deg,#1f0d26,#2e1540)',html:`<div class="pc"><div class="pe">Our Story</div><h2 class="ph">Built on conviction.</h2><p class="pp">18 people who care unreasonably about craft. Independent since 2016.</p><div class="pstat"><div><b>140+</b><span>Projects</span></div><div><b>9</b><span>Years</span></div></div></div>`},
+ {name:'Home',bg:'linear-gradient(135deg,#0d1a2e,#192640)',html:`<div class="pc"><div class="pe">Creative Studio</div><p class="ph">Design without compromise.</p><p class="pp">We craft digital products that earn attention and keep it.</p></div>`},
+ {name:'Work',bg:'linear-gradient(135deg,#0d1f15,#152e1e)',html:`<div class="pc"><div class="pe">Selected Work</div><p class="ph">The Portfolio</p><div class="pgrid">${['Atlas','Orbit','Prism','Lumen','Frame','Echo'].map(n=>`<div class="gi">${n}</div>`).join('')}</div></div>`},
+ {name:'About',bg:'linear-gradient(135deg,#1f0d26,#2e1540)',html:`<div class="pc"><div class="pe">Our Story</div><p class="ph">Built on conviction.</p><p class="pp">18 people who care unreasonably about craft. Independent since 2016.</p><div class="pstat"><div><b>140+</b><span>Projects</span></div><div><b>9</b><span>Years</span></div></div></div>`},
];
- const nav=document.getElementById('nav'),area=document.getElementById('page-area');
- const overlay=document.getElementById('dissolve-overlay');
- const curPage=document.getElementById('cur-page'),logEl=document.getElementById('trans-log');
- const durSl=document.getElementById('dur-sl'),durV=document.getElementById('dur-v');
- const granSl=document.getElementById('gran-sl'),granV=document.getElementById('gran-v');
- const styleSel=document.getElementById('style-sel'),biTog=document.getElementById('bi-tog'),maskTog=document.getElementById('mask-tog');
- let current=0,animating=false,dur=800,gran=8,history=[];
+ const nav=document.getElementById('nav'),area=document.getElementById('page-area'),overlay=document.getElementById('dissolve-overlay');
+ const biTog=document.getElementById('bi-tog'),slowTog=document.getElementById('slow-tog');
const motionOk=!window.matchMedia('(prefers-reduced-motion:reduce)').matches;
+ let current=0,animating=false,dur=800,gran=8,pattern='random',afterMove=null,wayBack=0,timers=[];
+ const pages=[],navBtns=[];
PAGES.forEach((p,i)=>{
- const d=document.createElement('div');d.className='page'+(i===0?' active':'');d.id='p'+i;d.style.background=p.bg;d.innerHTML=p.html;d.style.opacity=i===0?'1':'0';area.insertBefore(d,overlay);
- const b=document.createElement('button');b.className='nav-btn'+(i===0?' active':'');b.textContent=p.name;b.addEventListener('click',()=>navigate(i));nav.appendChild(b);
+ const d=document.createElement('div');d.className='page';d.style.background=p.bg;d.innerHTML=p.html;area.insertBefore(d,overlay);pages.push(d);
+ const b=document.createElement('button');b.type='button';b.className='nav-btn';b.textContent=p.name;
+ b.addEventListener('click',()=>navigate(i));nav.appendChild(b);navBtns.push(b);
});
- function updateNav(n){document.querySelectorAll('.nav-btn').forEach((b,i)=>b.classList.toggle('active',i===n));curPage.textContent=PAGES[n].name}
- function addLog(f,t){history.unshift(PAGES[f].name+' → '+PAGES[t].name);if(history.length>3)history.pop();logEl.innerHTML=history.map(l=>`<div class="log-row">${l}</div>`).join('')}
+ // Drops a timer's id once it fires, so `timers` only holds the ones still waiting.
+ function later(fn,wait){
+ const id=setTimeout(()=>{
+ const i=timers.indexOf(id);
+ if(i>-1)timers.splice(i,1);
+ fn();
+ },wait);
+ timers.push(id);
+ return id;
+ }
+ function cancel(id){
+ clearTimeout(id);
+ const i=timers.indexOf(id);
+ if(i>-1)timers.splice(i,1);
+ }
+
+ function updateNav(n){navBtns.forEach((b,i)=>{b.classList.toggle('active',i===n);b.setAttribute('aria-current',i===n?'page':'false')})}
+ // One page's resting look: its class alone shows or hides it (its background stays), and a page that is not on show cannot be reached
+ function rest(el,on){el.classList.toggle('active',on);el.inert=!on}
+ // The resting state for page n, at once: its page alone, no tiles, and no page fade left running under reduced motion
+ function showPage(n){
+ overlay.textContent='';
+ pages.forEach((el,i)=>{rest(el,i===n);el.getAnimations().forEach(a=>a.cancel())});
+ updateNav(n);
+ }
+
+ // Ends a transition: the demo is idle again, and a Show me run goes on to its next step
+ function finish(){
+ animating=false;
+ const then=afterMove;afterMove=null;
+ if(then)then();
+ }
+ // Stops everything at once and shows the resting state for `current`
+ function settle(){
+ timers.forEach(clearTimeout);timers=[];wayBack=0;afterMove=null;animating=false;
+ showPage(current);
+ }
function getDelays(n,style){
const total=n*n;
@@ -162,59 +234,75 @@ body{padding-top:46px}
});
}
- function buildTiles(n,bg,tileDur){
- overlay.innerHTML='';
- overlay.style.gridTemplateColumns=`repeat(${n},1fr)`;
- const delays=getDelays(n,styleSel.value);
- const showMask=maskTog.checked;
- Array.from({length:n*n},(_,i)=>{
+ // An n×n grid of transparent tiles over the page, each with its own delay; returns the delays
+ function buildTiles(n,bg,d,style){
+ const delays=getDelays(n,style);
+ const tiles=document.createDocumentFragment();
+ delays.forEach(k=>{
const t=document.createElement('div');t.className='dtile';
// stagger (33%) + per-tile fade (27%) = fully covered at 60%, when the swap fires
- t.style.cssText=`background:${bg};opacity:0;transition:opacity ${Math.round(tileDur*0.27)}ms ease ${Math.round(delays[i]*tileDur*0.33)}ms${showMask?';outline:1px solid rgba(255,100,100,.2)':''}`;
- overlay.appendChild(t);
+ t.style.cssText=`background:${bg};opacity:0;transition:opacity ${Math.round(d*0.27)}ms ease ${Math.round(k*d*0.33)}ms`;
+ tiles.appendChild(t);
});
+ overlay.textContent='';
+ overlay.style.gridTemplateColumns=`repeat(${n},1fr)`;
+ overlay.appendChild(tiles);
return delays;
}
- function navigate(next){
+ // next is where the visitor goes; then (a Show me run's next step) runs once the transition has ended
+ function navigate(next,then){
if(next===current||animating)return;
- const prev=current;current=next;updateNav(next);addLog(prev,next);
- if(!motionOk){document.querySelectorAll('.page').forEach((el,i)=>{el.style.opacity=i===next?'1':'0';el.classList.toggle('active',i===next)});return;}
- animating=true;doDissolve(prev,next);
+ const prev=current;current=next;updateNav(next);
+ afterMove=then||null;
+ // Reduced motion: no tiles, the pages cross in a plain fade (see the media rule above)
+ if(!motionOk){rest(pages[prev],false);rest(pages[next],true);finish();return}
+ animating=true;
+ doDissolve(prev,next);
}
function doDissolve(prev,next){
- const o=document.getElementById('p'+prev),n=document.getElementById('p'+next);
- const bg=getComputedStyle(o).background||'#060a10';
- const g=gran,d=dur; // freeze the settings for this run so mid-transition slider changes cannot desync the tiles
- buildTiles(g,bg,d);
- // Tiles appear over old page (dissolving it)
- requestAnimationFrame(()=>requestAnimationFrame(()=>{
- overlay.querySelectorAll('.dtile').forEach(t=>{t.style.opacity='1'});
- const swapAt=Math.round(d*0.6);
- setTimeout(()=>{
- o.classList.remove('active');o.style.opacity='0';
- n.classList.add('active');n.style.opacity='1';
- if(biTog.checked){
- // Dissolve in: tiles fade back out over the remaining 40%
- const tiles=[...overlay.querySelectorAll('.dtile')];
- const delays=getDelays(g,styleSel.value);
- tiles.forEach((t,i)=>{t.style.transition=`opacity ${Math.round(d*0.18)}ms ease ${Math.round(delays[i]*d*0.22)}ms`;t.style.opacity='0'});
- setTimeout(()=>{overlay.innerHTML='';animating=false},Math.round(d*0.4)+50);
- }else{
- overlay.innerHTML='';animating=false;
- }
- },swapAt);
- }));
+ // Everything a run needs is read now, so a setting changed mid-way cannot desync the tiles.
+ // d is the whole dissolve in ms (three times as long in slow motion).
+ const d=dur*(slowTog.checked?3:1),both=biTog.checked;
+ const delays=buildTiles(gran,PAGES[prev].bg,d,pattern);
+ const tiles=[...overlay.children];
+ void overlay.offsetWidth; // commit the transparent tiles before they are switched on
+ // Tiles appear over the old page (dissolving it)
+ tiles.forEach(t=>{t.style.opacity='1'});
+ later(()=>{
+ rest(pages[prev],false);rest(pages[next],true);
+ if(!both){overlay.textContent='';finish();return}
+ // Dissolve out: the tiles fade back out, in the same pattern, over the remaining 40%
+ tiles.forEach((t,i)=>{t.style.transition=`opacity ${Math.round(d*0.18)}ms ease ${Math.round(delays[i]*d*0.22)}ms`;t.style.opacity='0'});
+ later(()=>{overlay.textContent='';finish()},Math.round(d*0.4)+50);
+ },Math.round(d*0.6));
}
- granSl.addEventListener('input',()=>{gran=+granSl.value;granV.textContent=`${gran}×${gran}`});
- durSl.addEventListener('input',()=>{dur=+durSl.value;durV.textContent=dur+'ms'});
- document.getElementById('rst-btn').addEventListener('click',()=>{
- if(animating)return;const p=current;current=0;updateNav(0);if(p!==0)addLog(p,0);
- overlay.innerHTML='';document.querySelectorAll('.page').forEach((el,i)=>{el.classList.toggle('active',i===0);el.style.opacity=i===0?'1':'0'});animating=false;
- });
+ // Show me: one visit to the next page, a hold of 1200ms, and the way back to where the run started
+ function showMe(){
+ settle();
+ const start=current;
+ navigate((start+1)%PAGES.length,()=>{wayBack=later(()=>{wayBack=0;navigate(start)},1200)});
+ }
+ function reset(){current=0;settle()}
+
+ document.getElementById('btn-demo').addEventListener('click',showMe);
+ document.getElementById('btn-reset').addEventListener('click',reset);
+ // The visitor took over: cancel what the run has not started yet. A dissolve already under way finishes on its own.
+ document.addEventListener('hb:input',()=>{afterMove=null;cancel(wayBack);wayBack=0});
+
+ function choices(id,pick){
+ const buttons=document.querySelectorAll('#'+id+' button');
+ buttons.forEach(b=>b.addEventListener('click',()=>{
+ buttons.forEach(x=>{x.classList.toggle('on',x===b);x.setAttribute('aria-pressed',String(x===b))});
+ pick(b.dataset);
+ }));
+ }
+ choices('pattern-seg',d=>{pattern=d.pattern});
+ choices('size-seg',d=>{gran=+d.tiles});
+ choices('speed-seg',d=>{dur=+d.ms});
+ showPage(0);
</script>
-<script>(function(){var b=document.getElementById("ah-copy");if(!b)return;b.addEventListener("click",function(){fetch(location.href).then(function(r){return r.text();}).catch(function(){return document.documentElement.outerHTML;}).then(function(t){return navigator.clipboard.writeText(t);}).then(function(){b.textContent="Copied!";b.classList.add("ah-copied");setTimeout(function(){b.textContent="Copy source";b.classList.remove("ah-copied");},1500);}).catch(function(){b.textContent="Copy failed";setTimeout(function(){b.textContent="Copy source";},1500);});});})();</script>
</body>
</html>
diff --git a/index.html b/index.html
index fcb0c61d..addef03e 100644
--- a/index.html
+++ b/index.html
@@ -942,7 +942,7 @@ const CATS=[
['blur-transition','Blur Transition','Current page blurs and fades out, then new page sharpens in — a defocus wipe between scenes.'],
['elastic-transition','Elastic Transition','The new page slides in, goes too far and springs back. Best for playful apps.'],
['portal-zoom','Portal / Tunnel Zoom','The next page opens out of a circle you click. Best for big reveals.'],
- ['dissolve','Dissolve','Random tiles fade at staggered delays — a non-uniform wipe that reads as dissolving rather than fading.'],
+ ['dissolve','Dissolve','The page breaks into tiles that give way to the next. Best for photo galleries.'],
['flip-technique','FLIP Technique','First-Last-Invert-Play — CSS layout changes animated seamlessly by measuring position deltas.'],
]
},