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.

chore: the learning path and the idea lessons wait on feat/learn-pilot

matind810bcedd042
diff --git a/animations/01-scroll-based/parallax-scrolling/index.html b/animations/01-scroll-based/parallax-scrolling/index.html
index ec5bde49..3a77687b 100644
--- a/animations/01-scroll-based/parallax-scrolling/index.html
+++ b/animations/01-scroll-based/parallax-scrolling/index.html
@@ -82,7 +82,6 @@
<main class="hb-page">
<header class="hb-head">
<p class="hb-cat">01.02 · Scroll-Based</p>
- <p class="hb-lesson"><a href="../../../learn/">Learning path · Lesson 22 of 25</a></p>
<h1>Parallax Scrolling</h1>
<p class="hb-lede">Far layers move slower than near ones as you scroll. Best for hero scenes.</p>
</header>
@@ -172,7 +171,7 @@
<button class="hb-play" type="button" id="btn-top" data-hb-top><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"/></svg>Back to top</button>
</div>
<div class="hb-mode-notes" aria-live="polite">
- <p data-hb-for="inside" hidden><span class="say">Inside, the picture is four flat layers. As the box scrolls, the far layers move least and the near grass moves most. Scroll the box or press Play to watch.</span> <a href="../../../learn/far-things-move-slower/">The idea: far things move slower</a></p>
+ <p data-hb-for="inside" hidden>Inside, the picture is four flat layers. As the box scrolls, the far layers move least and the near grass moves most. Scroll the box or press Play to watch.</p>
<p data-hb-for="compare" hidden>On the left every layer moves the same, so the picture looks flat. On the right each layer moves its own amount, so it looks deep. Scroll the box or press Play to watch.</p>
</div>
</section>
@@ -232,12 +231,6 @@
<h2 id="hb-related-title">Similar animations</h2>
<div class="hb-rel-list"></div>
</section>
- <nav class="hb-lesson-nav" aria-label="Learning path">
- <h2 class="hb-lesson-title">Learning path</h2>
- <a class="hb-lesson-prev" href="../../../learn/far-things-move-slower/"><span>← Lesson 21</span><b>Far things move slower</b></a>
- <a class="hb-lesson-next" href="../../06-3d-advanced/parallax-3d-tilt/"><span>Lesson 23 →</span><b>Parallax 3D Tilt</b></a>
- <a class="hb-lesson-all" href="../../../learn/">All 25 lessons</a>
- </nav>
</main>
<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>
<script>
@@ -272,7 +265,7 @@
inside: 'The landscape pulled apart into its four layers, each labeled with how much it moves',
compare: 'Two copies of the landscape side by side, without parallax on the left and with parallax on the right',
};
- const insideSay = document.querySelector('[data-hb-for="inside"] .say');
+ const insideNote = document.querySelector('[data-hb-for="inside"]');
const compareNote = document.querySelector('[data-hb-for="compare"]');
let mode = 'normal';
let ticking = false;
@@ -329,7 +322,7 @@
L.tag.style.setProperty('--far', most ? s / most : 1);
});
const notes = NOTES[(motionMQ.matches ? 'still' : 'moving') + (flat ? 'Flat' : '')];
- insideSay.textContent = notes.inside;
+ insideNote.textContent = notes.inside;
compareNote.textContent = notes.compare;
}
diff --git a/assets/css/demo-page.css b/assets/css/demo-page.css
index 5f6e9c2e..b8813c86 100644
--- a/assets/css/demo-page.css
+++ b/assets/css/demo-page.css
@@ -195,24 +195,6 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}
.hb-rel b{font:700 18px/1.25 var(--hb-font);color:var(--hb-ink)}
.hb-rel span{font:400 14px/1.45 var(--hb-font);color:var(--hb-muted)}
-/* The learning path: the lesson line beside the category line (below it on phones), the previous and next lessons at the end
- of a page of the path, and an idea lesson's Why it works and Where you'll see it */
-.hb-lesson{margin:0;font:600 14px/1.3 var(--hb-font);letter-spacing:.02em}
-.hb-lesson a{color:var(--hb-dim);text-decoration:underline;text-decoration-color:var(--hb-edge-2);text-underline-offset:4px}
-.hb-lesson-nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding-top:clamp(28px,4vw,36px);border-top:1px solid var(--hb-line)}
-.hb-lesson-title{grid-column:1/-1;margin:0;font:700 22px/1.2 var(--hb-font);letter-spacing:-.01em;color:var(--hb-ink)}
-.hb-lesson-prev,.hb-lesson-next{display:flex;flex-direction:column;gap:6px;padding:18px 20px;border:1px solid rgba(255,255,255,.12);
- border-radius:10px;text-decoration:none}
-.hb-lesson-next{grid-column:2;text-align:right}
-.hb-lesson-prev span,.hb-lesson-next span{font:600 14px/1.3 var(--hb-font);color:var(--hb-accent)}
-.hb-lesson-prev b,.hb-lesson-next b{font:700 18px/1.25 var(--hb-font);color:var(--hb-ink)}
-.hb-lesson-all{grid-column:1/-1;justify-self:start;display:inline-flex;align-items:center;min-height:44px;color:var(--hb-dim);
- font:600 15px/1 var(--hb-font)}
-.hb-why,.hb-seen{padding-top:clamp(28px,4vw,36px);border-top:1px solid var(--hb-line)}
-.hb-why h2,.hb-seen h2{margin:0 0 12px;font:700 22px/1.2 var(--hb-font);letter-spacing:-.01em;color:var(--hb-ink)}
-.hb-why p{margin:0;max-width:68ch;font:400 17px/1.7 var(--hb-font);color:var(--hb-dim)}
-.hb-why p+p{margin-top:12px}
-
/* Footer: the site's name on the left, and its two links (Source on GitHub, Back to top) on the right. On phones the name
has a line of its own and the links share the line below it, one at each end. */
.hb-foot{box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center;gap:4px 24px;
@@ -231,8 +213,6 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}
.hb-options>summary:hover,.hb-prompt-more:hover{color:color-mix(in srgb,var(--hb-accent) 70%,#fff)}
.hb-copy:hover{background:#fff}
.hb-rel:hover{border-color:color-mix(in srgb,var(--hb-accent) 55%,transparent)}
- .hb-lesson-prev:hover,.hb-lesson-next:hover{border-color:color-mix(in srgb,var(--hb-accent) 55%,transparent)}
- .hb-lesson a:hover,.hb-lesson-all:hover{color:var(--hb-ink)}
.hb-foot a:hover{color:var(--hb-ink)}
}
@@ -259,13 +239,6 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}
.hb-bar{gap:4px;padding:0 8px}
.hb-bar .hb-home{font-size:15px}
}
-/* From 601px the lesson line shares the category line's row, at its right end, so the header grows no taller */
-@media(min-width:601px){
- .hb-head:has(> .hb-lesson){display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:16px}
- .hb-head:has(> .hb-lesson) > *{grid-column:1/-1}
- .hb-head:has(> .hb-lesson) > .hb-cat{grid-column:1}
- .hb-head:has(> .hb-lesson) > .hb-lesson{grid-column:2;justify-self:end;align-self:center}
-}
/* From 761px the mode switch sits at the right end of the Watch step's heading row (two columns: the heading, the switch). A player
bar with one or two controls leaves room beside it, so there the note for the mode in view sits next to the bar, under the switch,
and is on a laptop's first screen too. Three columns then: the player bar's own width, the room left over and the switch's width.
@@ -328,9 +301,6 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}
.hb-star-btn{width:100%}
.hb-foot{justify-content:space-between}
.hb-foot>span{flex-basis:100%}
- .hb-lesson a{display:inline-flex;align-items:center;min-height:44px}
- .hb-lesson-nav{grid-template-columns:minmax(0,1fr)}
- .hb-lesson-next{grid-column:auto}
}
@media(prefers-reduced-motion:reduce){
.hb-page .seg button,.hb-options>summary .hb-ic{transition:none}
diff --git a/assets/js/demo-page.js b/assets/js/demo-page.js
index 62a32c46..5ed9939d 100644
--- a/assets/js/demo-page.js
+++ b/assets/js/demo-page.js
@@ -7,7 +7,7 @@
* loops start paused).
* On scroll pages Play scrolls the box, Back to top jumps to its top and the visitor's own input stops it.
* The mode switch (Normal, See inside, Compare) marks the stage with data-hb-mode, shows that mode's note and sends
- * "hb:mode", so the page draws the mode. Pages without a prompt (the idea lessons) get everything but the prompt parts.
+ * "hb:mode", so the page draws the mode. Pages without a prompt get everything but the prompt parts.
* Opened from disk (file:), the page's links to folders open each folder's index.html instead of its listing.
* The pure helpers are exported for tests/demo-page.test.js. */
(function (root, factory) {
diff --git a/docs/superpowers/specs/2026-10-13-learn-pilot-design.md b/docs/superpowers/specs/2026-10-13-learn-pilot-design.md
index 16f5ff23..6b98ce5c 100644
--- a/docs/superpowers/specs/2026-10-13-learn-pilot-design.md
+++ b/docs/superpowers/specs/2026-10-13-learn-pilot-design.md
@@ -1,5 +1,9 @@
# Learn pilot: design
+> **Status (2026-10-13):** See inside (A) and Compare (B) roll out to every page by `2026-10-13-see-inside-compare-rollout-design.md`.
+> The learning path (C) and Motion basics (D) wait on `feat/learn-pilot`; the commit "chore: the learning path and the idea lessons
+> wait on feat/learn-pilot" took them off `feat/see-inside-compare`, and reverting it is the first step when they resume.
+
2026-10-13. The owner's goal for the handbook is to help people *understand* web animation by seeing it, with no code
on the site (see `2026-10-13-goal-and-roadmap.md`). From four ideas shown as mockups, the owner picked all four:
diff --git a/learn/far-things-move-slower/index.html b/learn/far-things-move-slower/index.html
deleted file mode 100644
index 45a678ad..00000000
--- a/learn/far-things-move-slower/index.html
+++ /dev/null
@@ -1,205 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Far things move slower — Animation Handbook</title>
- <meta name="description" content="Look out of a moving train: the fence rushes by, the mountains crawl and the moon seems to stay put. Your eyes use that difference to judge distance.">
- <link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/learn/far-things-move-slower/">
- <link rel="icon" type="image/png" sizes="96x96" href="../../favicon.png">
- <link rel="icon" type="image/svg+xml" href="../../favicon.svg">
- <link rel="apple-touch-icon" href="../../apple-touch-icon.png">
- <meta property="og:type" content="article">
- <meta property="og:site_name" content="Animation Handbook">
- <meta property="og:title" content="Far things move slower — Animation Handbook">
- <meta property="og:description" content="Look out of a moving train: the fence rushes by, the mountains crawl and the moon seems to stay put. Your eyes use that difference to judge distance.">
- <meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/learn/far-things-move-slower/">
- <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="Far things move slower — Animation Handbook">
- <meta name="twitter:description" content="Look out of a moving train: the fence rushes by, the mountains crawl and the moon seems to stay put. Your eyes use that difference to judge distance.">
- <meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <style>
- :root{--ui-accent:#c8f169}
- *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
- .stage{--ft-vh:1vh;position:relative;overflow:hidden;background:#141b33}
- /* Each layer is twice the window's width and repeats halfway, so it can slide forever without a seam */
- .strip{position:absolute;top:0;left:0;width:200%;height:100%;will-change:transform}
- .strip svg{position:absolute;inset:0;width:100%;height:100%}
- .sky{background:linear-gradient(#141b33,#2e2a4a 70%,#3d3456)}
- .moon{position:absolute;top:16%;height:18%;aspect-ratio:1;border-radius:50%;background:#f3e7c4}
- .moon.a{left:14%} .moon.b{left:64%}
- /* The stars are round dots placed by percent, not drawn in the stretched pictures, so they stay round. They fill one window;
- the script adds a second copy one window along, so the loop has no seam */
- .stars{position:absolute;top:0;bottom:0;left:0;width:50%}
- .stars+.stars{left:50%}
- .stars i{position:absolute;width:var(--s,2px);height:var(--s,2px);border-radius:50%;background:#fff;opacity:var(--o,.5)}
- .speeds{position:absolute;inset:0;list-style:none;pointer-events:none}
- .speed{position:absolute;left:clamp(10px,3vw,24px);display:flex;align-items:center;gap:8px;padding:5px 10px;border-radius:999px;
- background:rgba(11,11,13,.8);color:#f4f4f2;font:600 13px/1.2 var(--hb-font)}
- .speed span{font-weight:400;color:#d6d6da}
- .speed i{display:block;height:6px;width:calc(var(--bar,0) * 72px);border-radius:3px;background:var(--ui-accent)}
- .speed:nth-child(1){top:5%} .speed:nth-child(2){top:38%} .speed:nth-child(3){top:60%} .speed:nth-child(4){top:82%}
- @media(prefers-reduced-motion:reduce){.strip{will-change:auto}}
- /* The lede runs to two lines here, one more than on most pages: from 601px wide the stage gives that line back, so the stage and
- the player bar stay on the first screen. --ft-vh: the small viewport height where known */
- @supports(height:1svh){.stage{--ft-vh:1svh}}
- @media(min-width:601px){.hb-page .stage{--hb-stage-h:clamp(300px,calc(100 * var(--ft-vh) - 450px),440px)}}
- @media(min-width:601px) and (max-height:760px){.hb-page .stage{--hb-stage-h:clamp(260px,calc(100 * var(--ft-vh) - 356px),440px)}}
- </style>
- <link rel="stylesheet" href="../../assets/css/demo-page.css?v=9">
- <script src="../../assets/js/demo-page.js?v=9" defer></script>
-</head>
-<body class="hb hb-learn" data-hb-kind="loop">
-<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="../../animations/03-page-transitions/flip-technique/" rel="prev" aria-label="Previous lesson: FLIP Technique"><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 lesson: </span>FLIP Technique</span></a><a href="../../animations/01-scroll-based/parallax-scrolling/" rel="next" aria-label="Next lesson: Parallax Scrolling"><span><span class="hb-dir">Next lesson: </span>Parallax Scrolling</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>
- <a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg><span>Star on GitHub</span></a>
-</nav>
-<main class="hb-page">
- <header class="hb-head">
- <p class="hb-cat">Lesson 21 of 25 · Idea</p>
- <h1>Far things move slower</h1>
- <p class="hb-lede">Look out of a moving train: the fence rushes by, the mountains crawl and the moon seems to stay put. Your eyes use that difference to judge distance.</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">Watch it</h2><p>A view from a train window. Each layer slides past at its own speed.</p></div>
- </div>
- <div class="stage" id="stage" role="img" aria-label="A view from a train window: a moon that stays put, mountains that crawl, hills that go faster and a fence that rushes by">
- <div class="strip sky">
- <div class="stars" aria-hidden="true">
- <i style="left:9%;top:30%"></i>
- <i style="left:20%;top:18%;--s:3px;--o:.65"></i>
- <i style="left:53%;top:28%"></i>
- <i style="left:58%;top:11%;--s:3px;--o:.65"></i>
- <i style="left:68%;top:24%"></i>
- <i style="left:77%;top:8%;--o:.55"></i>
- <i style="left:85%;top:21%;--s:3px;--o:.6"></i>
- <i style="left:94%;top:31%;--o:.45"></i>
- </div>
- <div class="moon a"></div><div class="moon b"></div>
- </div>
- <div class="strip far">
- <svg viewBox="0 0 1600 400" preserveAspectRatio="none" aria-hidden="true">
- <polygon fill="#3b4270" points="0,250 70,190 140,230 230,150 320,215 400,175 480,225 560,160 650,220 730,185 800,250 870,190 940,230 1030,150 1120,215 1200,175 1280,225 1360,160 1450,220 1530,185 1600,250 1600,400 0,400"/>
- </svg>
- </div>
- <div class="strip mid">
- <svg viewBox="0 0 1600 400" preserveAspectRatio="none" aria-hidden="true">
- <path fill="#2a5a52" d="M0 300 C 100 250, 200 250, 300 290 S 500 330, 600 280 S 750 270, 800 300 C 900 250, 1000 250, 1100 290 S 1300 330, 1400 280 S 1550 270, 1600 300 L 1600 400 L 0 400 Z"/>
- </svg>
- </div>
- <div class="strip near">
- <svg viewBox="0 0 1600 400" preserveAspectRatio="none" aria-hidden="true">
- <defs><pattern id="posts" width="50" height="400" patternUnits="userSpaceOnUse"><rect x="10" y="300" width="8" height="62" fill="#e6d5ad"/></pattern></defs>
- <rect y="355" width="1600" height="45" fill="#1b2a26"/>
- <rect y="316" width="1600" height="5" fill="#d9c7a0"/>
- <rect y="336" width="1600" height="5" fill="#d9c7a0"/>
- <rect width="1600" height="400" fill="url(#posts)"/>
- </svg>
- </div>
- <ul class="speeds" aria-hidden="true">
- <li class="speed"><b>Moon</b><span></span><i></i></li>
- <li class="speed"><b>Mountains</b><span></span><i></i></li>
- <li class="speed"><b>Hills</b><span></span><i></i></li>
- <li class="speed"><b>Fence</b><span></span><i></i></li>
- </ul>
- </div>
- <div class="hb-player">
- <button class="hb-play" type="button" id="btn-pause" data-hb-pause data-state="playing"><svg class="hb-ic hb-i-pause" viewBox="0 0 24 24" aria-hidden="true"><rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/></svg><svg class="hb-ic hb-i-play" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3l14 9-14 9z"/></svg><span class="hb-pause-label">Pause</span></button>
- </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>Give every layer the same speed and watch the depth disappear.</p></div>
- </div>
- <div class="hb-settings">
- <div class="hb-setting">
- <label class="hb-switch-row"><span>Same speed for everything</span><input class="hb-switch" type="checkbox" role="switch" id="same" autocomplete="off"></label>
- <p class="hb-hint">On, the scene slides like one flat picture. Off, near things pass faster and it looks deep.</p>
- </div>
- </div>
- </section>
-
- <section class="hb-why" aria-labelledby="hb-why-title">
- <h2 id="hb-why-title">Why it works</h2>
- <p>Near things cross your view quickly and far things slowly, so your eyes read the difference as distance. Give a picture's far layers small moves and its near layers big moves, and a flat picture looks deep. That is the whole idea behind parallax, and it works best with a few layers and gentle speeds.</p>
- </section>
-
- <section class="hb-seen" aria-labelledby="hb-seen-title">
- <h2 id="hb-seen-title">Where you'll see it</h2>
- <div class="hb-rel-list">
- <a class="hb-rel" href="../../animations/01-scroll-based/parallax-scrolling/"><b>Parallax Scrolling</b><span>Far layers move slower than near ones as you scroll.</span></a>
- <a class="hb-rel" href="../../animations/01-scroll-based/parallax-depth-of-field/"><b>Parallax Depth-of-Field</b><span>Layers move at their own speed as the focus shifts.</span></a>
- <a class="hb-rel" href="../../animations/06-3d-advanced/2-5d-pseudo-3d/"><b>2.5D / Pseudo-3D</b><span>Flat layers slide by different amounts, faking depth.</span></a>
- <a class="hb-rel" href="../../animations/06-3d-advanced/depth-map-photo/"><b>Depth-Map Photo</b><span>A flat photo turns 3D as you point: near parts shift more.</span></a>
- <a class="hb-rel" href="../../animations/07-ambient-background/wave-layers/"><b>Wave Layers</b><span>Layers of waves drift sideways, each at its own speed.</span></a>
- <a class="hb-rel" href="../../animations/07-ambient-background/grid-dot-pattern-parallax/"><b>Grid / Dot Pattern Parallax</b><span>A dot grid shifts gently against your pointer for depth.</span></a>
- </div>
- </section>
-
- <nav class="hb-lesson-nav" aria-label="Learning path">
- <h2 class="hb-lesson-title">Learning path</h2>
- <a class="hb-lesson-prev" href="../../animations/03-page-transitions/flip-technique/"><span>← Lesson 20</span><b>FLIP Technique</b></a>
- <a class="hb-lesson-next" href="../../animations/01-scroll-based/parallax-scrolling/"><span>Lesson 22 →</span><b>Parallax Scrolling</b></a>
- <a class="hb-lesson-all" href="../">All 25 lessons</a>
- </nav>
-</main>
-<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>
-<script>
- const FRAME = 1000 / 60;
- // Window widths per second: the moon stays put, the mountains crawl, the hills go faster, the fence rushes by
- const SPEEDS = [0, 0.02, 0.07, 0.4];
- const SAME = 0.1;
- const WORDS = ['stays put', 'slow', 'faster', 'fastest'];
- const stage = document.getElementById('stage');
- const strips = [...stage.querySelectorAll('.strip')];
- const tags = [...stage.querySelectorAll('.speed')];
- const same = document.getElementById('same');
- // The second copy of the stars, one window along
- const field = stage.querySelector('.stars');
- field.after(field.cloneNode(true));
- // How far each layer has slid, in window widths: 0 to 1, then it starts over. Not in pixels, so a window that is resized
- // while the page is paused cannot leave a layer outside the stage
- const pos = strips.map(() => 0);
- let lastT = null, raf = 0, paused = false;
-
- function speedOf(i) { return same.checked ? SAME : SPEEDS[i]; }
- function frame(ts) {
- const dt = lastT === null ? 0 : Math.min(ts - lastT, 50);
- lastT = ts;
- strips.forEach((s, i) => {
- pos[i] = (pos[i] + speedOf(i) / 60 * (dt / FRAME)) % 1;
- // A layer is two windows wide, so half of its own width is one window: the whole loop
- s.style.transform = `translate3d(${(-pos[i] * 50).toFixed(3)}%,0,0)`;
- });
- raf = requestAnimationFrame(frame);
- }
- function start() { if (!raf && !paused && !document.hidden) { lastT = null; raf = requestAnimationFrame(frame); } }
- function stop() { cancelAnimationFrame(raf); raf = 0; }
- // Pause and Play (and reduced motion, which starts the page paused) come from the shared script
- document.addEventListener('hb:pause', e => { paused = e.detail.paused; if (paused) stop(); else start(); });
- document.addEventListener('visibilitychange', () => { if (document.hidden) stop(); else start(); });
-
- // Each label says how fast its layer goes, in words and as a bar a share of the fence's speed
- function describe() {
- tags.forEach((t, i) => {
- t.querySelector('span').textContent = same.checked ? 'same speed' : WORDS[i];
- t.style.setProperty('--bar', speedOf(i) / SPEEDS[3]);
- });
- stage.setAttribute('aria-label', same.checked
- ? 'A view from a train window where every layer slides at the same speed, like one flat picture'
- : 'A view from a train window: a moon that stays put, mountains that crawl, hills that go faster and a fence that rushes by');
- }
- same.addEventListener('change', describe);
- describe();
- // Under reduced motion the scene waits for Play (the shared script pauses it too, but only once it has loaded)
- if (!matchMedia('(prefers-reduced-motion: reduce)').matches) start();
-</script>
-</body>
-</html>
diff --git a/learn/follows-the-scroll/index.html b/learn/follows-the-scroll/index.html
deleted file mode 100644
index 7b2b6410..00000000
--- a/learn/follows-the-scroll/index.html
+++ /dev/null
@@ -1,168 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Follows the scroll — Animation Handbook</title>
- <meta name="description" content="Some animations play on their own, like a video. Others follow your scroll: they move when you scroll and stop when you stop.">
- <link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/learn/follows-the-scroll/">
- <link rel="icon" type="image/png" sizes="96x96" href="../../favicon.png">
- <link rel="icon" type="image/svg+xml" href="../../favicon.svg">
- <link rel="apple-touch-icon" href="../../apple-touch-icon.png">
- <meta property="og:type" content="article">
- <meta property="og:site_name" content="Animation Handbook">
- <meta property="og:title" content="Follows the scroll — Animation Handbook">
- <meta property="og:description" content="Some animations play on their own, like a video. Others follow your scroll: they move when you scroll and stop when you stop.">
- <meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/learn/follows-the-scroll/">
- <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="Follows the scroll — Animation Handbook">
- <meta name="twitter:description" content="Some animations play on their own, like a video. Others follow your scroll: they move when you scroll and stop when you stop.">
- <meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <style>
- :root{--ui-accent:#c8f169;--ball:28px}
- *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
- .stage{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px;background:#0b0b0d;overflow:hidden;--fs-vh:1vh}
- /* The line under the title takes two lines here, one more than on the animation pages, so from 601px wide (where the shared heights apply)
- the stage gives that line back, and the player bar stays on a laptop's first screen. --fs-vh: the small viewport height where known */
- @supports(height:1svh){.stage{--fs-vh:1svh}}
- @media(min-width:601px){.stage{--hb-stage-h:clamp(300px,calc(100 * var(--fs-vh) - 450px),440px)}}
- @media(min-width:601px) and (max-height:760px){.stage{--hb-stage-h:clamp(260px,calc(100 * var(--fs-vh) - 356px),440px)}}
- .panel{position:relative;min-width:0;background:#14151b}
- /* Both views start at the same height, about where a centered block would for the stage's height, so the two tracks line up
- whatever the text under them does (the stage is 300px on phones) */
- .view{display:flex;flex-direction:column;gap:14px;height:100%;padding:clamp(14px,3vw,28px);padding-top:clamp(24px,calc((var(--hb-stage-h,300px) - 190px) / 2),90px)}
- .name{font:700 clamp(15px,2vw,19px)/1.2 var(--hb-font);color:#f4f4f2}
- @media(max-width:349px){.name{min-height:2.4em}} /* "Follows the scroll" takes two lines here, so both titles keep two and the tracks stay level */
- .says{font:400 clamp(13px,1.6vw,15px)/1.45 var(--hb-font);color:#c4c4cb}
- .track{position:relative;height:var(--ball);border-bottom:2px dashed rgba(255,255,255,.4)}
- .runner{position:absolute;inset:0;will-change:transform}
- .ball{width:var(--ball);height:var(--ball);border-radius:50%;background:var(--ui-accent)}
- /* Plays by itself: the ball crosses its track on a timer, however the visitor scrolls. Its button pauses and plays it. */
- .clock .runner{animation:cross 2.4s ease-in-out infinite alternate}
- .clock[data-ball="paused"] .runner{animation-play-state:paused}
- @keyframes cross{to{transform:translateX(calc(100% - var(--ball)))}}
- .toggle{align-self:flex-start;min-width:44px;min-height:44px;padding:0 14px;border:1px solid rgba(255,255,255,.18);border-radius:8px;background:none;color:#f4f4f2;font:500 14px/1.2 var(--hb-font);text-align:left;cursor:pointer}
- @media(hover:hover){.toggle:hover{border-color:var(--hb-edge-2)}}
- /* Follows the scroll: this panel is the box that scrolls. Its view stays put. The script writes how far the box is scrolled
- (0 to 1) into --p, and the ball and the thin cue on the box's right edge are placed from it here. The box shows a third of
- what it holds, so the thumb of the cue is a third of its rail. */
- .scroll{overflow-y:auto;scrollbar-width:none}
- .scroll::-webkit-scrollbar{display:none}
- .scroll .tall{height:300%}
- .scroll .view{position:sticky;top:0;height:calc(100% / 3)}
- .scroll .runner{transform:translateX(calc(var(--p,0) * (100% - var(--ball))))}
- .cue{position:absolute;top:12px;right:5px;bottom:12px;width:4px;border-radius:2px;background:rgba(255,255,255,.12);pointer-events:none}
- .thumb{height:calc(100% / 3);border-radius:inherit;background:rgba(255,255,255,.4);will-change:transform;transform:translateY(calc(var(--p,0) * 200%))}
- .where{display:block;margin-top:4px;font:600 14px/1.3 var(--hb-font);color:var(--ui-accent);white-space:nowrap;font-variant-numeric:tabular-nums}
- /* Reduced motion: the left ball starts paused (this holds it before the script has run), and its button can still play it */
- @media(prefers-reduced-motion:reduce){.clock:not([data-ball]) .runner{animation-play-state:paused}}
- </style>
- <link rel="stylesheet" href="../../assets/css/demo-page.css?v=9">
- <script src="../../assets/js/demo-page.js?v=9" defer></script>
-</head>
-<body class="hb hb-learn" data-hb-kind="scroll" data-hb-autoplay data-hb-motion-note="The ball that plays by itself starts paused">
-<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="../../animations/04-micro-interactions/loading-spinner/" rel="prev" aria-label="Previous lesson: Loading Spinner"><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 lesson: </span>Loading Spinner</span></a><a href="../../animations/01-scroll-based/reveal-on-scroll/" rel="next" aria-label="Next lesson: Reveal on Scroll"><span><span class="hb-dir">Next lesson: </span>Reveal on Scroll</span><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a></span>
- <a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg><span>Star on GitHub</span></a>
-</nav>
-<main class="hb-page">
- <header class="hb-head">
- <p class="hb-cat">Lesson 11 of 25 · Idea</p>
- <h1>Follows the scroll</h1>
- <p class="hb-lede">Some animations play on their own, like a video. Others follow your scroll: they move when you scroll and stop when you stop.</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">Scroll it</h2><p>Scroll the right box, or press Play and it scrolls for you. The left ball keeps its own time.</p></div>
- </div>
- <div class="stage" id="stage" role="region" aria-label="Two boxes side by side: a ball that plays by itself, and a ball that follows the scroll of its box">
- <div class="panel clock" id="clock">
- <div class="view">
- <p class="name">Plays by itself</p>
- <div class="track"><div class="runner"><div class="ball"></div></div></div>
- <p class="says">Moves on a timer, however you scroll.</p>
- <button class="toggle" type="button" id="btn-ball">Pause the ball</button>
- </div>
- </div>
- <div class="panel scroll" id="scroll-box" data-hb-scroller tabindex="0" role="group" aria-label="A box to scroll: its ball follows the scroll">
- <div class="tall">
- <div class="view">
- <p class="name">Follows the scroll</p>
- <div class="track"><div class="runner"><div class="ball"></div></div></div>
- <p class="says">Goes where the scroll goes. <span class="where" id="where">0% scrolled</span></p>
- <div class="cue" aria-hidden="true"><div class="thumb"></div></div>
- </div>
- </div>
- </div>
- </div>
- <div class="hb-player">
- <button class="hb-play" type="button" id="btn-scroll" data-hb-autoscroll><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>Play</button>
- <button class="hb-play" type="button" id="btn-top" data-hb-top><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"/></svg>Back to top</button>
- </div>
- </section>
-
- <section class="hb-why" aria-labelledby="hb-why-title">
- <h2 id="hb-why-title">Why it works</h2>
- <p>When an animation follows the scroll, the visitor controls it: scroll slowly and it moves slowly, scroll back and it plays backward, stop and it stops. That ties the movement to reading the page, so it feels like part of it. An animation that plays by itself runs on a clock instead, however the visitor scrolls.</p>
- </section>
-
- <section class="hb-seen" aria-labelledby="hb-seen-title">
- <h2 id="hb-seen-title">Where you'll see it</h2>
- <div class="hb-rel-list">
- <a class="hb-rel" href="../../animations/01-scroll-based/parallax-scrolling/"><b>Parallax Scrolling</b><span>Far layers move slower than near ones as you scroll.</span></a>
- <a class="hb-rel" href="../../animations/01-scroll-based/scrub-animation/"><b>Scrub Animation</b><span>Scroll plays it forward and back, like dragging a video.</span></a>
- <a class="hb-rel" href="../../animations/01-scroll-based/progress-bar/"><b>Progress Bar</b><span>A bar fills as you read down the page.</span></a>
- <a class="hb-rel" href="../../animations/01-scroll-based/text-fill-on-scroll/"><b>Text Fill on Scroll</b><span>Words light up one by one as you scroll.</span></a>
- <a class="hb-rel" href="../../animations/06-3d-advanced/scroll-driven-3d-rotation/"><b>Scroll-Driven 3D Rotation</b><span>Scrolling turns a 3D cube from pose to pose.</span></a>
- </div>
- </section>
-
- <nav class="hb-lesson-nav" aria-label="Learning path">
- <h2 class="hb-lesson-title">Learning path</h2>
- <a class="hb-lesson-prev" href="../../animations/04-micro-interactions/loading-spinner/"><span>← Lesson 10</span><b>Loading Spinner</b></a>
- <a class="hb-lesson-next" href="../../animations/01-scroll-based/reveal-on-scroll/"><span>Lesson 12 →</span><b>Reveal on Scroll</b></a>
- <a class="hb-lesson-all" href="../">All 25 lessons</a>
- </nav>
-</main>
-<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>
-<script>
- // The right ball and the cue sit as far along as the box is scrolled, read once per frame while the box scrolls.
- const box = document.getElementById('scroll-box');
- const where = document.getElementById('where');
- let ticking = false;
- let said = where.textContent;
- function follow() {
- const max = box.scrollHeight - box.clientHeight;
- const p = max > 0 ? box.scrollTop / max : 0;
- box.style.setProperty('--p', p.toFixed(4)); // the style sheet places the ball and the cue from this
- const now = `${Math.round(p * 100)}% scrolled`;
- if (now !== said) { where.textContent = now; said = now; }
- ticking = false;
- }
- box.addEventListener('scroll', () => {
- if (!ticking) { requestAnimationFrame(follow); ticking = true; }
- }, { passive: true });
- // A resize changes how far the box can scroll, so the ball and the readout are read again
- addEventListener('resize', follow);
- follow();
-
- // The left ball plays by itself until the visitor pauses it. Under reduced motion it starts paused.
- const clock = document.getElementById('clock');
- const toggle = document.getElementById('btn-ball');
- const reduce = matchMedia('(prefers-reduced-motion: reduce)');
- function setBall(paused) {
- clock.dataset.ball = paused ? 'paused' : 'playing';
- toggle.textContent = paused ? 'Play the ball' : 'Pause the ball';
- }
- toggle.addEventListener('click', () => setBall(clock.dataset.ball !== 'paused'));
- function holdBall(e) { if (e.matches) setBall(true); }
- if (reduce.addEventListener) reduce.addEventListener('change', holdBall);
- else if (reduce.addListener) reduce.addListener(holdBall);
- setBall(reduce.matches);
-</script>
-</body>
-</html>
diff --git a/learn/index.html b/learn/index.html
deleted file mode 100644
index 3da97ff6..00000000
--- a/learn/index.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Learn web animation — Animation Handbook</title>
- <meta name="description" content="25 short lessons, from easy to advanced. You watch and try; you never write code.">
- <link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/learn/">
- <link rel="icon" type="image/png" sizes="96x96" href="../favicon.png">
- <link rel="icon" type="image/svg+xml" href="../favicon.svg">
- <link rel="apple-touch-icon" href="../apple-touch-icon.png">
- <meta property="og:type" content="website">
- <meta property="og:site_name" content="Animation Handbook">
- <meta property="og:title" content="Learn web animation — Animation Handbook">
- <meta property="og:description" content="25 short lessons, from easy to advanced. You watch and try; you never write code.">
- <meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/learn/">
- <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="Learn web animation — Animation Handbook">
- <meta name="twitter:description" content="25 short lessons, from easy to advanced. You watch and try; you never write code.">
- <meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">
- <style>
- :root{--ui-accent:#c8f169}
- .hb-chapter{display:flex;flex-direction:column;gap:14px;padding-top:clamp(28px,4vw,36px);border-top:1px solid var(--hb-line)}
- .hb-chapter h2{margin:0;font:700 clamp(22px,2.6vw,26px)/1.2 var(--hb-font);letter-spacing:-.015em;color:var(--hb-ink)}
- .hb-chapter h2 span{display:block;margin-bottom:4px;font:600 14px/1.3 var(--hb-font);letter-spacing:.04em;color:var(--hb-accent)}
- .hb-path{display:flex;flex-direction:column;gap:10px;margin:0;padding:0;list-style:none}
- .hb-path li > a,.hb-path li > div{display:grid;grid-template-columns:44px minmax(0,1fr);column-gap:16px;row-gap:2px;align-items:center;
- padding:14px 18px;border:1px solid rgba(255,255,255,.12);border-radius:10px;text-decoration:none}
- .hb-path .n{grid-row:1/span 3;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:44px;height:44px;border-radius:50%;
- border:1px solid var(--hb-edge);font:700 16px/1 var(--hb-font);color:var(--hb-ink)}
- .hb-path [data-kind="idea"] .n{border-color:var(--hb-accent);background:var(--hb-accent);color:#0b0b0d}
- .hb-path [data-soon] .n{border-color:var(--hb-edge);background:none;color:var(--hb-muted)}
- .hb-path .k{font:600 13px/1.3 var(--hb-font);color:var(--hb-muted)}
- .hb-path b{font:700 18px/1.25 var(--hb-font);color:var(--hb-ink)}
- .hb-path .line{font:400 15px/1.45 var(--hb-font);color:var(--hb-dim)}
- .hb-path [data-soon] > div{border-style:dashed}
- .hb-path [data-soon] b,.hb-path [data-soon] .line{color:var(--hb-muted)}
- @media(hover:hover){.hb-path a:hover{border-color:color-mix(in srgb,var(--hb-accent) 55%,transparent)}}
- </style>
- <link rel="stylesheet" href="../assets/css/demo-page.css?v=9">
- <script src="../assets/js/demo-page.js?v=9" defer></script>
-</head>
-<body class="hb hb-learn">
-<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>
- <a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub"><svg class="hb-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1-4.4-4.3 6.1-.9z"/></svg><span>Star on GitHub</span></a>
-</nav>
-<main class="hb-page">
- <header class="hb-head">
- <p class="hb-cat">Learning path</p>
- <h1>Learn web animation</h1>
- <p class="hb-lede">25 short lessons, from easy to advanced. You watch and try; you never write code.</p>
- </header>
-
- <section class="hb-chapter" aria-labelledby="ch-1">
- <h2 id="ch-1"><span>Chapter 1</span>Appear and leave</h2>
- <ol class="hb-path" role="list">
- <li data-step="1" data-kind="idea" data-soon><div><span class="n">1</span><span class="k">Idea · Not built yet</span><b>How long it takes</b><span class="line">Fast feels snappy and slow feels calm: pick the time that fits the moment.</span></div></li>
- <li data-step="2" data-kind="animation"><a href="../animations/02-entrance-and-exit/fade-in-out/"><span class="n">2</span><span class="k">Animation</span><b>Fade In / Fade Out</b><span class="line">Fades in to appear and fades out to leave.</span></a></li>
- <li data-step="3" data-kind="idea" data-soon><div><span class="n">3</span><span class="k">Idea · Not built yet</span><b>Slowing down</b><span class="line">Real things speed up and slow down, so smooth animations do too.</span></div></li>
- <li data-step="4" data-kind="animation"><a href="../animations/02-entrance-and-exit/slide-in/"><span class="n">4</span><span class="k">Animation</span><b>Slide In</b><span class="line">Travels into place from one edge.</span></a></li>
- <li data-step="5" data-kind="animation"><a href="../animations/02-entrance-and-exit/scale-in/"><span class="n">5</span><span class="k">Animation</span><b>Scale In / Zoom In</b><span class="line">Grows from smaller to full size.</span></a></li>
- </ol>
- </section>
-
- <section class="hb-chapter" aria-labelledby="ch-2">
- <h2 id="ch-2"><span>Chapter 2</span>Answer the visitor</h2>
- <ol class="hb-path" role="list">
- <li data-step="6" data-kind="idea" data-soon><div><span class="n">6</span><span class="k">Idea · Not built yet</span><b>Answer every action</b><span class="line">A press, a tap or a hover gets a quick, small reply, so people know it worked.</span></div></li>
- <li data-step="7" data-kind="animation"><a href="../animations/04-micro-interactions/button-press-scale/"><span class="n">7</span><span class="k">Animation</span><b>Button Press Scale</b><span class="line">Shrinks as you press it and springs back as you let go.</span></a></li>
- <li data-step="8" data-kind="animation"><a href="../animations/04-micro-interactions/hover-state/"><span class="n">8</span><span class="k">Animation</span><b>Hover State Animation</b><span class="line">Six ways a card can react when you point at it.</span></a></li>
- <li data-step="9" data-kind="animation"><a href="../animations/04-micro-interactions/toggle-switch/"><span class="n">9</span><span class="k">Animation</span><b>Toggle / Switch Slide</b><span class="line">The knob slides across as the switch turns on or off.</span></a></li>
- <li data-step="10" data-kind="animation"><a href="../animations/04-micro-interactions/loading-spinner/"><span class="n">10</span><span class="k">Animation</span><b>Loading Spinner</b><span class="line">Six small shapes loop to show that something is loading.</span></a></li>
- </ol>
- </section>
-
- <section class="hb-chapter" aria-labelledby="ch-3">
- <h2 id="ch-3"><span>Chapter 3</span>Move with the scroll</h2>
- <ol class="hb-path" role="list">
- <li data-step="11" data-kind="idea"><a href="follows-the-scroll/"><span class="n">11</span><span class="k">Idea</span><b>Follows the scroll</b><span class="line">Some animations play by themselves; others move only when you scroll.</span></a></li>
- <li data-step="12" data-kind="animation"><a href="../animations/01-scroll-based/reveal-on-scroll/"><span class="n">12</span><span class="k">Animation</span><b>Reveal on Scroll</b><span class="line">Cards appear as they cross a line in the box.</span></a></li>
- <li data-step="13" data-kind="idea" data-soon><div><span class="n">13</span><span class="k">Idea · Not built yet</span><b>One after another</b><span class="line">A short wait between items leads the eye through a group.</span></div></li>
- <li data-step="14" data-kind="animation"><a href="../animations/01-scroll-based/stagger-reveal/"><span class="n">14</span><span class="k">Animation</span><b>Stagger Reveal</b><span class="line">Items in a group appear one after another as it scrolls in.</span></a></li>
- <li data-step="15" data-kind="animation"><a href="../animations/01-scroll-based/progress-bar/"><span class="n">15</span><span class="k">Animation</span><b>Progress Bar</b><span class="line">A bar fills as you read down the page.</span></a></li>
- </ol>
- </section>
-
- <section class="hb-chapter" aria-labelledby="ch-4">
- <h2 id="ch-4"><span>Chapter 4</span>Change pages</h2>
- <ol class="hb-path" role="list">
- <li data-step="16" data-kind="idea" data-soon><div><span class="n">16</span><span class="k">Idea · Not built yet</span><b>Keep your place</b><span class="line">When the page changes, motion shows where things went.</span></div></li>
- <li data-step="17" data-kind="animation"><a href="../animations/03-page-transitions/crossfade/"><span class="n">17</span><span class="k">Animation</span><b>Crossfade Transition</b><span class="line">The old page fades out as the new one fades in.</span></a></li>
- <li data-step="18" data-kind="animation"><a href="../animations/03-page-transitions/slide-transition/"><span class="n">18</span><span class="k">Animation</span><b>Slide Transition</b><span class="line">Pages slide across, and going back slides the other way.</span></a></li>
- <li data-step="19" data-kind="animation"><a href="../animations/03-page-transitions/shared-element-transition/"><span class="n">19</span><span class="k">Animation</span><b>Shared Element Transition</b><span class="line">A picture grows from the list into the next page's header.</span></a></li>
- <li data-step="20" data-kind="animation"><a href="../animations/03-page-transitions/flip-technique/"><span class="n">20</span><span class="k">Animation</span><b>FLIP Technique</b><span class="line">Cards glide to their new places when the layout changes.</span></a></li>
- </ol>
- </section>
-
- <section class="hb-chapter" aria-labelledby="ch-5">
- <h2 id="ch-5"><span>Chapter 5</span>Depth and 3D</h2>
- <ol class="hb-path" role="list">
- <li data-step="21" data-kind="idea"><a href="far-things-move-slower/"><span class="n">21</span><span class="k">Idea</span><b>Far things move slower</b><span class="line">Near things pass quickly and far things slowly: that is how depth looks.</span></a></li>
- <li data-step="22" data-kind="animation"><a href="../animations/01-scroll-based/parallax-scrolling/"><span class="n">22</span><span class="k">Animation</span><b>Parallax Scrolling</b><span class="line">Far layers move slower than near ones as you scroll.</span></a></li>
- <li data-step="23" data-kind="animation"><a href="../animations/06-3d-advanced/parallax-3d-tilt/"><span class="n">23</span><span class="k">Animation</span><b>Parallax 3D Tilt</b><span class="line">A card tilts toward your pointer, and a light slides over it.</span></a></li>
- <li data-step="24" data-kind="animation"><a href="../animations/06-3d-advanced/flip-card-3d/"><span class="n">24</span><span class="k">Animation</span><b>3D Flip Card</b><span class="line">A card turns over in 3D to show its back.</span></a></li>
- <li data-step="25" data-kind="idea" data-soon><div><span class="n">25</span><span class="k">Idea · Not built yet</span><b>Less is more</b><span class="line">When not to animate, and how to respect people who ask for less motion.</span></div></li>
- </ol>
- </section>
-</main>
-<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>
-</body>
-</html>
diff --git a/tests/demo-page.test.js b/tests/demo-page.test.js
index 2bc9e339..65ea0148 100644
--- a/tests/demo-page.test.js
+++ b/tests/demo-page.test.js
@@ -129,7 +129,7 @@ test('motionNote says what reduced motion changes in the player bar', () => {
// any) and the window's clipboard; no other test gets any of them. A link test passes `links` ({ protocol, hrefs }): the page is
// served over that protocol (http: otherwise) and holds one link for each href.
// `extra` ({ modes, noPrompt }): modes adds the mode switch (Normal, See inside, Compare) and one note for See inside and one
-// for Compare; noPrompt leaves the prompt out, as on an idea lesson.
+// for Compare; noPrompt leaves the prompt out.
function standInPage(kind, reduced, bodyAttributes, copy, links, extra) {
const opts = extra || {};
const timers = [], sent = [];
@@ -275,7 +275,7 @@ test('a scroll page with an empty sentence of its own gets the usual note, and o
assert.equal(standInPage('scroll', false, { 'data-hb-motion-note': 'The layers stay still while the box scrolls' }).player.children.length, 0);
});
-test('a page with no prompt, such as an idea lesson, still gets its player: a scroll page scrolls on arrival and notes reduced motion', () => {
+test('a page with no prompt still gets its player: a scroll page scrolls on arrival and notes reduced motion', () => {
const page = standInPage('scroll', false, {}, null, null, { noPrompt: true });
page.runTimers();
assert.equal(page.play.clicks, 1);
diff --git a/tests/learn.test.js b/tests/learn.test.js
deleted file mode 100644
index 5b499cb8..00000000
--- a/tests/learn.test.js
+++ /dev/null
@@ -1,189 +0,0 @@
-// Static checks for the Learn pages: the learning path on learn/index.html (the single source of truth for the path), the idea
-// lessons in learn/<slug>/, and the lesson line and lesson nav on every page of the path that has them.
-// Run from the repo root: node --test "tests/*.test.js"
-const test = require('node:test');
-const assert = require('node:assert/strict');
-const fs = require('node:fs');
-const path = require('node:path');
-
-const ROOT = path.resolve(__dirname, '..');
-const LEARN = path.join(ROOT, 'learn');
-const ANIM = path.join(ROOT, 'animations');
-const read = f => fs.readFileSync(f, 'utf8');
-const count = (s, sub) => s.split(sub).length - 1;
-const HUB = read(path.join(LEARN, 'index.html'));
-const HOME = read(path.join(ROOT, 'index.html'));
-
-// The steps of the path in page order: { n, kind, soon, href (null while not built), title, num, label, line, body }.
-// num, label and line are what the visitor reads on the step: its number, its kind and its one line.
-const spanOf = (body, cls) => (body.match(new RegExp(`<span class="${cls}">([^<]*)</span>`)) || [])[1];
-const STEPS = [...HUB.matchAll(/<li data-step="(\d+)" data-kind="(idea|animation)"( data-soon)?>([\s\S]*?)<\/li>/g)].map(m => {
- const link = m[4].match(/<a href="([^"]+)"/);
- return { n: Number(m[1]), kind: m[2], soon: !!m[3], href: link ? link[1] : null, title: (m[4].match(/<b>([^<]+)<\/b>/) || [])[1],
- num: spanOf(m[4], 'n'), label: spanOf(m[4], 'k'), line: spanOf(m[4], 'line'), body: m[4] };
-});
-const dirOf = href => path.resolve(LEARN, href);
-const h1Of = dir => ((read(path.join(dir, 'index.html')).match(/<h1>([^<]+)<\/h1>/) || [])[1] || '').replace(/&amp;/g, '&');
-const LESSONS = fs.readdirSync(LEARN, { withFileTypes: true })
- .filter(d => d.isDirectory() && fs.existsSync(path.join(LEARN, d.name, 'index.html'))).map(d => path.join(LEARN, d.name));
-// Every Learn page: the hub and each idea lesson.
-const PAGES = [path.join(LEARN, 'index.html'), ...LESSONS.map(d => path.join(d, 'index.html'))];
-const decode = s => s.replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
-const FOOTER = '<footer class="hb-foot"><span>Animation Handbook</span><a href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">Source on GitHub</a><a href="#top">Back to top ↑</a></footer>';
-const STAR = '<a class="hb-star" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener" aria-label="Star on GitHub">';
-const version = (html, file) => (html.match(new RegExp(`demo-page\\.${file}\\?v=(\\d+)`)) || [])[1];
-
-test('the path has 25 steps in five chapters of five, numbered in order', () => {
- assert.deepEqual(STEPS.map(s => s.n), Array.from({ length: 25 }, (_, i) => i + 1));
- const chapters = [...HUB.matchAll(/<section class="hb-chapter"[\s\S]*?<\/section>/g)].map(m => m[0]);
- assert.deepEqual(chapters.map(c => count(c, '<li data-step=')), [5, 5, 5, 5, 5]);
- // Each chapter is one ordered list. VoiceOver drops the list role when the list has no bullets, so the role is written out.
- for (const [i, c] of chapters.entries()) {
- assert.equal(count(c, '<ol class="hb-path"'), 1, `chapter ${i + 1} is an ordered list`);
- assert.equal(count(c, '<ol class="hb-path" role="list">'), 1, `chapter ${i + 1}'s list keeps its list role`);
- }
-});
-
-test('every step shows its own number, its kind (Idea, Animation, or Idea · Not built yet) and a line', () => {
- for (const s of STEPS) {
- assert.equal(s.num, String(s.n), `step ${s.n} shows its own number`);
- assert.ok(!s.soon || s.kind === 'idea', `step ${s.n}: only an idea can be not built yet`);
- const label = s.soon ? 'Idea · Not built yet' : s.kind === 'idea' ? 'Idea' : 'Animation';
- assert.equal(s.label, label, `step ${s.n} shows its kind`);
- assert.ok(s.line && s.line.trim(), `step ${s.n} has its line`);
- }
-});
-
-test('every built step links to an existing page and shows its title; a step not built yet has no link and says so', () => {
- for (const s of STEPS) {
- if (s.soon) {
- assert.equal(s.href, null, `step ${s.n} has no link`);
- assert.ok(s.body.includes('Not built yet'), `step ${s.n} says Not built yet`);
- continue;
- }
- assert.ok(s.href, `step ${s.n} has a link`);
- const dir = dirOf(s.href);
- assert.ok(fs.existsSync(path.join(dir, 'index.html')), `step ${s.n}: ${s.href} exists`);
- assert.equal(s.title, h1Of(dir), `step ${s.n} shows the page's title`);
- assert.ok(dir.startsWith((s.kind === 'idea' ? LEARN : ANIM) + path.sep), `step ${s.n}: ideas live in learn/, animations in animations/`);
- }
-});
-
-test('every idea lesson in learn/ is a built step of the path', () => {
- for (const dir of LESSONS) {
- assert.ok(STEPS.some(s => s.href && s.kind === 'idea' && dirOf(s.href) === dir), `${path.basename(dir)} is a built idea step`);
- }
-});
-
-// Every page of the path that has a lesson line or lesson nav: each idea lesson, and any animation page that carries them.
-const onPath = STEPS.filter(s => s.href).map(s => ({ step: s, dir: dirOf(s.href) }))
- .filter(p => fs.existsSync(path.join(p.dir, 'index.html')) && read(path.join(p.dir, 'index.html')).includes('class="hb-lesson'));
-for (const { step, dir } of onPath) {
- test(`step ${step.n} (${step.title}): its lesson line and lesson nav match the Learn page`, () => {
- const html = read(path.join(dir, 'index.html'));
- const learnHref = path.relative(dir, LEARN).split(path.sep).join('/') + '/';
- const line = step.kind === 'idea' ? `<p class="hb-cat">Lesson ${step.n} of 25 · Idea</p>`
- : `<p class="hb-lesson"><a href="${learnHref}">Learning path · Lesson ${step.n} of 25</a></p>`;
- assert.ok(html.includes(line), `lesson line: ${line}`);
- const nav = html.match(/<nav class="hb-lesson-nav" aria-label="Learning path">([\s\S]*?)<\/nav>/);
- assert.ok(nav, 'lesson nav');
- assert.ok(nav[1].includes('<h2 class="hb-lesson-title">Learning path</h2>'), 'lesson nav title');
- const prev = STEPS[step.n - 2], next = STEPS[step.n];
- for (const [cls, other, label] of [['hb-lesson-prev', prev, prev && `← Lesson ${prev.n}`], ['hb-lesson-next', next, next && `Lesson ${next.n} →`]]) {
- const a = nav[1].match(new RegExp(`<a class="${cls}" href="([^"]+)"><span>([^<]+)</span><b>([^<]+)</b></a>`));
- if (!other) { assert.equal(a, null, `no ${cls} at the end of the path`); continue; }
- assert.ok(other.href, `step ${other.n}, next to step ${step.n}, is built`);
- assert.ok(a, cls);
- assert.equal(a[2], label, `${cls} label`);
- assert.equal(a[3], other.title, `${cls} title`);
- assert.equal(path.resolve(dir, a[1]), dirOf(other.href), `${cls} opens step ${other.n}`);
- }
- assert.ok(nav[1].includes(`<a class="hb-lesson-all" href="${learnHref}">All 25 lessons</a>`), 'All 25 lessons');
- if (step.kind === 'idea') {
- for (const [rel, other, word] of [['prev', prev, 'Previous'], ['next', next, 'Next']]) {
- const a = html.match(new RegExp(`<a href="([^"]+)" rel="${rel}" aria-label="${word} lesson: ([^"]+)">`));
- if (!other) { assert.equal(a, null, `no top bar ${rel} link at the end of the path`); continue; }
- assert.ok(a, `top bar ${rel} link`);
- assert.equal(path.resolve(dir, a[1]), dirOf(other.href), `top bar ${rel} opens step ${other.n}`);
- assert.equal(a[2], other.title, `top bar ${rel} names step ${other.n}`);
- }
- }
- });
-}
-
-for (const file of PAGES) {
- const name = path.relative(ROOT, file).split(path.sep).join('/');
- test(`${name}: the shared frame (top bar with the Star link, footer, shared files at the home page's version) and no code`, () => {
- const html = read(file);
- assert.match(html, /<body class="hb hb-learn"/, 'body class hb hb-learn');
- assert.equal(count(html, '<nav class="hb-bar"'), 1);
- assert.ok(html.includes(STAR), 'the Star link in the top bar');
- assert.equal(count(html, '<main class="hb-page">'), 1);
- assert.equal(count(html, '<header class="hb-head">'), 1);
- assert.ok(html.replace(/>\s+</g, '><').includes(FOOTER), 'the shared footer');
- // The home page links only demo-page.js (it has its own styles), so its version N is the script's. Without a version on the
- // home page the comparison below could pass with nothing on either side.
- const homeVersion = version(HOME, 'js');
- assert.ok(homeVersion, 'the home page links demo-page.js with a version');
- for (const f of ['css', 'js']) assert.equal(version(html, f), homeVersion, `demo-page.${f} at the home page's version`);
- assert.ok(!/`|<code|<pre/.test(html.replace(/<script[\s\S]*?<\/script>/g, '').replace(/<style[\s\S]*?<\/style>/g, '')), 'no code on the page');
- assert.ok(!html.includes('hb-view'), 'no old hb-view markup');
- });
-}
-
-// What search engines, social sites and the browser tab show, as on every animation page: the tab title is the heading and the site
-// name, the descriptions are the lede, and the address is the page's own folder.
-for (const file of PAGES) {
- const name = path.relative(ROOT, file).split(path.sep).join('/');
- test(`${name}: the tab title, the descriptions and the address say what the page says`, () => {
- const html = read(file);
- const h1 = decode((html.match(/<h1>([^<]+)<\/h1>/) || [])[1] || '');
- const lede = decode(((html.match(/<p class="hb-lede">([\s\S]*?)<\/p>/) || [])[1] || '').replace(/<[^>]+>/g, '')).replace(/\s+/g, ' ').trim();
- assert.ok(h1, 'the page has a heading');
- assert.ok(lede, 'the page has a lede');
- const meta = attr => { const m = html.match(new RegExp(`<meta ${attr} content="([^"]*)">`)); assert.ok(m, `<meta ${attr}> is there`); return decode(m[1]); };
- const title = `${h1} — Animation Handbook`;
- assert.equal(decode((html.match(/<title>([^<]*)<\/title>/) || [])[1] || ''), title, '<title> is the heading and the site name');
- for (const attr of ['property="og:title"', 'name="twitter:title"']) assert.equal(meta(attr), title, attr);
- for (const attr of ['name="description"', 'property="og:description"', 'name="twitter:description"']) assert.equal(meta(attr), lede, `${attr} is the lede`);
- const address = `https://matinmonshizadeh.github.io/animation-handbook/${path.relative(ROOT, path.dirname(file)).split(path.sep).join('/')}/`;
- const canonical = html.match(/<link rel="canonical" href="([^"]*)">/);
- assert.ok(canonical, 'the canonical link is there');
- assert.equal(canonical[1], address, 'the canonical address is the live address of the page\'s folder');
- assert.equal(meta('property="og:url"'), address, 'og:url is the live address of the page\'s folder');
- });
-}
-
-test('the Learn page names itself and has five chapters', () => {
- assert.ok(HUB.includes('<h1>Learn web animation</h1>'));
- assert.ok(HUB.includes('<p class="hb-lede">25 short lessons, from easy to advanced. You watch and try; you never write code.</p>'));
- assert.equal(count(HUB, '<section class="hb-chapter"'), 5);
-});
-
-for (const dir of LESSONS) {
- test(`learn/${path.basename(dir)}: an idea lesson with a stage, Why it works, Where you'll see it and no prompt`, () => {
- const html = read(path.join(dir, 'index.html'));
- const body = html.match(/<body class="hb hb-learn" data-hb-kind="(once|loop|scroll|do)"( data-hb-autoplay)?(?: data-hb-motion-note="[^"]*")?>/);
- assert.ok(body, 'the body declares the page kind');
- for (const part of ['<section class="hb-step hb-watch"', '<div class="hb-player">', '<section class="hb-why"', '<section class="hb-seen"', '<nav class="hb-lesson-nav"']) {
- assert.equal(count(html, part), 1, `exactly one ${part}`);
- }
- assert.ok(!html.includes('hb-prompt'), 'no prompt');
- if (body[1] === 'loop') assert.equal(count(html, 'data-hb-pause'), 1, 'a loop has Pause');
- if (body[1] === 'scroll') {
- assert.ok(body[2], 'a scroll lesson scrolls once on arrival');
- assert.equal(count(html, 'data-hb-autoscroll'), 1, 'Play');
- assert.equal(count(html, 'data-hb-top'), 1, 'Back to top');
- }
- const why = html.match(/<section class="hb-why"[\s\S]*?<\/section>/)[0].replace(/<[^>]+>/g, ' ');
- const sentences = why.replace('Why it works', '').split(/[.!?](?:\s|$)/).filter(s => s.trim()).length;
- assert.ok(sentences >= 2 && sentences <= 4, `Why it works has ${sentences} sentences`);
- const seen = [...html.match(/<section class="hb-seen"[\s\S]*?<\/section>/)[0].matchAll(/<a class="hb-rel" href="([^"]+)"><b>([^<]+)<\/b>/g)];
- assert.ok(seen.length >= 3 && seen.length <= 6, `${seen.length} pages in Where you'll see it`);
- for (const [, href, title] of seen) {
- const target = path.resolve(dir, href);
- assert.ok(target.startsWith(ANIM + path.sep) && fs.existsSync(path.join(target, 'index.html')), `${href} is an animation page`);
- assert.equal(title, h1Of(target), `${href} shows the page's title`);
- }
- });
-}
diff --git a/tests/pages.test.js b/tests/pages.test.js
index d48532a9..e93a81a5 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -6,6 +6,7 @@ const fs = require('node:fs');
const path = require('node:path');
const { sections, table } = require('./helpers/markdown.js');
const vm = require('node:vm');
+const { execFileSync } = require('node:child_process');
const ROOT = path.resolve(__dirname, '..');
const ANIM = path.join(ROOT, 'animations');
@@ -558,12 +559,11 @@ test('the shared stylesheet keeps choice buttons at least 44px wide', () => {
assert.ok(rulesFor('.hb-page .seg button').some(rule => /(^|;)\s*min-width:\s*44px\s*(;|$)/.test(rule.body)), 'a choice button is at least 44px wide');
});
-test('the shared stylesheet draws the mode switch beside the Watch heading and the note beside a short player bar from 761px, hides an empty notes box, and styles the lesson line, the lesson nav and the idea lessons\' sections', () => {
+test('the shared stylesheet draws the mode switch beside the Watch heading and the note beside a short player bar from 761px, and hides an empty notes box', () => {
const css = read(path.join(ROOT, 'assets', 'css', 'demo-page.css'));
const rules = cssRules(css);
const has = sel => rules.some(r => r.selector.split(',').map(s => s.trim()).includes(sel));
- for (const sel of ['.hb-page .seg.hb-modes', '.hb-mode-notes p', '.hb-lesson', '.hb-lesson a', '.hb-lesson-nav', '.hb-lesson-prev',
- '.hb-lesson-next', '.hb-lesson-all', '.hb-why p', '.hb-seen']) assert.ok(has(sel), sel);
+ for (const sel of ['.hb-page .seg.hb-modes', '.hb-mode-notes p']) assert.ok(has(sel), sel);
// The empty box is the aria-live region that makes a screen reader read each note out, so it must stay rendered: display:none
// would take it out of the accessibility tree, and the first note shown might not be announced. It is hidden to the eye and taken
// out of the flow instead, which takes no room and adds no gap. The box counts as empty until a note is un-hidden, and a note is
@@ -604,7 +604,28 @@ test('the shared stylesheet draws the mode switch beside the Watch heading and t
assert.equal(count(css, '> .hb-mode-notes{'), 1, 'no other rule places the note, so phones keep it under the player bar');
assert.ok(phones.includes('.hb-page .seg.hb-modes button{flex:1 1 0'), 'the block up to 760px is found (it holds the equal mode buttons)');
assert.ok(!/\.hb-watch|\.hb-mode-notes|\.hb-player/.test(phones), 'up to 760px nothing makes the Watch step a grid or places the note or the player bar');
- assert.match(css, /@media\(min-width:601px\)\{\s*\.hb-head:has\(> \.hb-lesson\)\{display:grid/, 'from 601px the lesson line shares the category row');
+});
+
+// The learning path and the idea lessons wait on feat/learn-pilot (docs/superpowers/specs/2026-10-13-see-inside-compare-rollout-design.md,
+// section 5): no tracked page links into learn/ and the shared stylesheet keeps none of their rules. Delete this test when the
+// learning path resumes (its first step reverts the clean-up commit, which takes this test away too).
+test('while the learning path waits, no tracked page links into learn/ and the shared stylesheet has none of its rules', () => {
+ let pages;
+ try {
+ pages = execFileSync('git', ['ls-files', '--', '*.html'], { cwd: ROOT, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).split(/\r?\n/).filter(Boolean);
+ } catch {
+ // No git here (a copy from a source zip): every page in the folder, outside git's, the agents' and the packages' folders
+ const walk = dir => fs.readdirSync(path.join(ROOT, dir), { withFileTypes: true }).flatMap(e => e.isDirectory()
+ ? (['.git', '.claude', '.superpowers', 'node_modules'].includes(e.name) ? [] : walk(path.join(dir, e.name)))
+ : e.name.endsWith('.html') ? [path.join(dir, e.name)] : []);
+ pages = walk('');
+ }
+ assert.ok(pages.length > 100, `the tracked pages are found (${pages.length})`);
+ const linking = pages.filter(f => /href="(?:(?:\.\.\/)+|\/animation-handbook\/)?learn\//.test(read(path.join(ROOT, f))));
+ assert.deepEqual(linking, [], 'pages that link into learn/');
+ assert.ok(!fs.existsSync(path.join(ROOT, 'learn')), 'the learn/ folder is gone');
+ const css = read(path.join(ROOT, 'assets', 'css', 'demo-page.css')).replace(/\/\*[\s\S]*?\*\//g, '');
+ for (const name of ['hb-lesson', 'hb-why', 'hb-seen', 'hb-learn', 'hb-path']) assert.ok(!css.includes(name), `no ${name} rule`);
});
test('the home page uses Schibsted Grotesk and asks what to animate', () => {
diff --git a/tools/check-pages.mjs b/tools/check-pages.mjs
index f2faf0f5..8411b1dd 100644
--- a/tools/check-pages.mjs
+++ b/tools/check-pages.mjs
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// Browser check for guided-steps demo pages: a development tool, not part of the site.
// Needs the local Chrome and a static server for the repo (python -m http.server 8731 --bind 127.0.0.1).
-// Usage: node tools/check-pages.mjs [--base http://127.0.0.1:8731] [--out <folder>] <page or category folder, home or learn>...
+// Usage: node tools/check-pages.mjs [--base http://127.0.0.1:8731] [--out <folder>] <page or category folder, or home>...
// e.g. node tools/check-pages.mjs animations/02-entrance-and-exit
// node tools/check-pages.mjs home checks the home page at the same six setups: overflow, small targets on phones,
// the search box and the place tiles on the first screen, the tile counts and the eight Start cards. The desktop run
@@ -39,8 +39,6 @@
// mode (the stage is cut out of it and compared, and the screenshot taken again, after putting the box back, up to three more
// times if it differs). A stage that never comes to rest is a problem of its own, and nothing is compared with a frame taken in
// mid-movement.
-// "learn" stands for the Learn page and every idea lesson in learn/: the page checks run there too, without the prompt parts
-// (chips, What it is), and each lesson's kind is worked like any other page's. "learn/index.html" is the Learn page alone.
// Without --out every run writes into a new hb-check-<date>-<time>-<process id> folder (--out picks another one).
// Nothing is emptied or removed, so runs going on at the same time, in other lanes or terminals, never wipe each
// other's screenshots. The temporary Chrome profile (hb-chrome-* in the temp folder) is removed when the run ends, trying
@@ -73,24 +71,15 @@ const OUT = givenOut || join(tmpdir(), `hb-check-${stamp}-${process.pid}`);
const isPage = folder => existsSync(join(ROOT, folder, 'index.html'));
// A category folder (no index.html, but page folders inside) is expanded to its pages, so the call works
// in shells that do not expand wildcards, such as PowerShell.
-const pages = args.map(p => (p === 'home' ? p : p.replace(/\\/g, '/').replace(/^\.?\//, '')))
+const pages = args.map(p => (p === 'home' ? p : p.replace(/\\/g, '/').replace(/^\.?\//, '').replace(/\/?(index\.html)?$/, '/')))
.flatMap(p => {
- // "learn/index.html" is the Learn page alone.
- if (p === 'learn/index.html') return ['learn/'];
- if (p !== 'home') p = p.replace(/\/?(index\.html)?$/, '/');
- // "learn" and "learn/" stand for the Learn page and every idea lesson in its folder.
- if (p === 'learn/') {
- const lessons = existsSync(join(ROOT, 'learn')) ? readdirSync(join(ROOT, 'learn'), { withFileTypes: true })
- .filter(d => d.isDirectory() && isPage(`learn/${d.name}`)).map(d => `learn/${d.name}/`).sort() : [];
- return ['learn/', ...lessons];
- }
if (p === 'home' || isPage(p) || !existsSync(join(ROOT, p))) return [p];
const inside = readdirSync(join(ROOT, p), { withFileTypes: true })
.filter(d => d.isDirectory() && isPage(p + d.name)).map(d => `${p}${d.name}/`).sort();
return inside.length ? inside : [p];
});
if (!pages.length) {
- console.error('Usage: node tools/check-pages.mjs [--base URL] [--out DIR] <page or category folder, home or learn>...');
+ console.error('Usage: node tools/check-pages.mjs [--base URL] [--out DIR] <page or category folder, or home>...');
process.exit(2);
}
mkdirSync(OUT, { recursive: true });
@@ -110,12 +99,11 @@ const CHECK = `(() => {
const r = el => el.getBoundingClientRect();
const phone = innerWidth <= 600;
const problems = [];
- const learn = document.body.classList.contains('hb-learn');
if (!document.querySelector('.hb-page')) problems.push('not a guided-steps page');
// Measured against clientWidth: under mobile emulation the browser widens innerWidth to fit overflowing content.
if (document.documentElement.scrollWidth > document.documentElement.clientWidth + 1) problems.push('horizontal overflow');
if (phone) {
- const small = [...document.querySelectorAll('.hb-bar a, .hb-page button, .hb-page summary, .hb-page select, .hb-page input[type=range], .hb-page .hb-text, label.hb-toggle, label.hb-switch-row, .hb-foot a, .hb-star-row a, .hb-rel, .hb-lesson a, .hb-lesson-nav a, .hb-path a')]
+ const small = [...document.querySelectorAll('.hb-bar a, .hb-page button, .hb-page summary, .hb-page select, .hb-page input[type=range], .hb-page .hb-text, label.hb-toggle, label.hb-switch-row, .hb-foot a, .hb-star-row a, .hb-rel')]
.filter(el => el.getClientRects().length && !el.closest('.stage'))
.filter(el => { const b = r(el); return b.width < 44 || b.height < 44; })
.map(el => el.tagName.toLowerCase() + (el.getAttribute('class') ? '.' + el.getAttribute('class').split(' ')[0] : '') + ' ' + Math.round(r(el).width) + 'x' + Math.round(r(el).height));
@@ -127,11 +115,10 @@ const CHECK = `(() => {
const shown = el => { for (let n = el; n && n !== tryIt; n = n.parentElement) { if (n.hidden || n.hasAttribute('data-hb-skip') || getComputedStyle(n).display === 'none') return false; } return true; };
const controls = tryIt ? [...tryIt.querySelectorAll('input[type=range], input[type=checkbox], input[type=text], textarea, select, .seg, .swatches')].filter(shown).length : 0;
const chips = document.querySelectorAll('.hb-chips li').length;
- // Learn pages have no prompt, so no chips, and no README
- if (!learn && chips !== controls) problems.push('chips ' + chips + ' vs settings ' + controls);
+ if (chips !== controls) problems.push('chips ' + chips + ' vs settings ' + controls);
const what = document.querySelector('.hb-what-text');
- if (!learn && (!what || !what.querySelector('p'))) problems.push('What it is is missing');
- else if (!learn && what.querySelector('a[href="README.md"]')) problems.push('What it is did not load from the README');
+ if (!what || !what.querySelector('p')) problems.push('What it is is missing');
+ else if (what.querySelector('a[href="README.md"]')) problems.push('What it is did not load from the README');
const loop = document.querySelector('[data-hb-loop]');
const switches = [...document.querySelectorAll('[data-hb-loop], [data-hb-slowmo]')].map(s =>
({ name: s.matches('[data-hb-loop]') ? 'Loop' : 'Slow motion', checked: s.checked, disabled: s.disabled }));