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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
feat: the Famous effects page's frame in the home page's look (top bar, the not-connected line, jump row, Seen one we should add?, footer) with its script for previews, jumps, Copy prompt and the phone clamp, and a Famous effect issue template
matin2650fce1e9b1
diff --git a/.github/ISSUE_TEMPLATE/famous_effect.yml b/.github/ISSUE_TEMPLATE/famous_effect.ymlnew file mode 100644index 00000000..0390342f--- /dev/null+++ b/.github/ISSUE_TEMPLATE/famous_effect.yml@@ -0,0 +1,37 @@+name: Famous effect+description: Suggest an effect from a well-known website for the Famous effects page.+title: "[famous effect] "+labels: ["enhancement"]+body:+ - type: markdown+ attributes:+ value: Describe the effect in your own words, please, with no screenshots, videos or code from the site. The page shows each effect only with the handbook's own demos.+ - type: input+ id: address+ attributes:+ label: The site's address+ description: The public page where the effect shows without signing in.+ placeholder: https://example.com/+ validations:+ required: true+ - type: input+ id: where+ attributes:+ label: Where on the page+ description: For example the menu at the top, or the cards on the home page.+ - type: textarea+ id: what+ attributes:+ label: What you see+ description: In your own words, what moves and what starts it (the page opening, scrolling, pointing at something or pressing it).+ validations:+ required: true+ - type: checkboxes+ id: checks+ attributes:+ label: Before you send it+ options:+ - label: I described the effect in my own words.+ required: true+ - label: I attached no screenshots, videos or code from the site.+ required: truediff --git a/famous/index.html b/famous/index.htmlnew file mode 100644index 00000000..3aa6a6d9--- /dev/null+++ b/famous/index.html@@ -0,0 +1,360 @@+<!DOCTYPE html>+<html lang="en">+<head>+<meta charset="UTF-8">+<meta name="viewport" content="width=device-width, initial-scale=1.0">+<title>Famous effects — Animation Handbook</title>+<meta name="description" content="Effects people admire on well-known websites, the handbook animations that make something similar, and a prompt to build your own.">+<meta name="robots" content="index, follow, max-image-preview:large">+<meta name="theme-color" content="#f8f7f4">+<link rel="canonical" href="https://matinmonshizadeh.github.io/animation-handbook/famous/">+<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">++<!-- Open Graph -->+<meta property="og:type" content="website">+<meta property="og:site_name" content="Animation Handbook">+<meta property="og:title" content="Famous effects — Animation Handbook">+<meta property="og:description" content="Effects people admire on well-known websites, the handbook animations that make something similar, and a prompt to build your own.">+<meta property="og:url" content="https://matinmonshizadeh.github.io/animation-handbook/famous/">+<meta property="og:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">+<meta property="og:image:width" content="1200">+<meta property="og:image:height" content="630">++<!-- Twitter -->+<meta name="twitter:card" content="summary_large_image">+<meta name="twitter:title" content="Famous effects — Animation Handbook">+<meta name="twitter:description" content="Effects people admire on well-known websites, the handbook animations that make something similar, and a prompt to build your own.">+<meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png">+<script>+// The theme is the visitor's own pick (ah-theme), else the system's, as on the home page.+function setTheme(t){document.documentElement.dataset.theme=t;document.querySelector('meta[name="theme-color"]').content=t==='dark'?'#0e0e11':'#f8f7f4';}+(function(){var t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';try{t=localStorage.getItem('ah-theme')||t;}catch(e){}setTheme(t);})();</script>+<style>+@font-face{font-family:'Schibsted Grotesk';src:url('../assets/fonts/schibsted-latin-ext.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}+@font-face{font-family:'Schibsted Grotesk';src:url('../assets/fonts/schibsted-latin.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}++/* the home page's colors and type, copied as they are (tests/famous.test.js compares them) */+:root{+ --bg:#f8f7f4;--surface:#ffffff;--ink:#16161b;--ink-2:#45454f;--muted:#676771;+ --line:#e5e3dc;--line-2:#efede8;--brand:#2f5bea;--ok:#157a43;+ --shadow:0 1px 2px rgba(22,22,27,.04),0 8px 24px rgba(22,22,27,.06);+ --shadow-2:0 2px 4px rgba(22,22,27,.05),0 18px 40px rgba(22,22,27,.11);+ --c1:#6ea8ff;--c2:#5fd88a;--c3:#b98cff;--c4:#ff9d5c;--c5:#ff6f8b;--c6:#3fd6c4;--c7:#ffce5a;+ --disp:'Schibsted Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;--text:var(--disp);+ --ease:cubic-bezier(.22,1,.36,1);--gut:clamp(16px,4vw,40px);+ color-scheme:light;+}+:root[data-theme="dark"]{+ --bg:#0e0e11;--surface:#17171c;--ink:#f4f4f2;--ink-2:#c6c6cc;--muted:#9c9ca5;+ --line:rgba(255,255,255,.13);--line-2:rgba(255,255,255,.07);--brand:#86a8ff;+ --shadow:0 1px 2px rgba(0,0,0,.3),0 8px 24px rgba(0,0,0,.25);+ --shadow-2:0 2px 4px rgba(0,0,0,.35),0 18px 40px rgba(0,0,0,.45);+ color-scheme:dark;+}+*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}+[hidden]{display:none!important}+html,body{background:var(--bg);color:var(--ink)}+body{font-family:var(--text);font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;overflow-x:hidden}+a{color:inherit}+button{font:inherit;color:inherit}+:focus-visible{outline:3px solid var(--brand);outline-offset:3px}+.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}+.skip{position:absolute;left:16px;top:-80px;z-index:100;padding:10px 16px;border-radius:10px;background:var(--ink);color:var(--bg);font-weight:700;text-decoration:none}+.skip:focus{top:12px}+.i{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}+.wrap{width:min(1280px,calc(100% - 2 * var(--gut)));margin-inline:auto}++/* the top bar and the footer: the home page's */+.top{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:76px}+.brand{display:inline-flex;align-items:center;gap:12px;min-height:44px;text-decoration:none;font-size:17px;font-weight:800;letter-spacing:-.015em;white-space:nowrap}+.mark{width:30px;height:30px;flex:none}+.mark .ring{fill:var(--bg);stroke:currentColor;stroke-width:1.8}+.mark .ball{fill:currentColor}+.nav{display:flex;align-items:center;gap:6px}+.lnk{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 14px;border-radius:999px;text-decoration:none;font-size:15px;font-weight:600;color:var(--ink-2);white-space:nowrap}+.lnk[aria-current="page"]{color:var(--ink);background:var(--line-2)}+.icon-btn{display:inline-grid;place-items:center;width:44px;height:44px;border-radius:999px;border:0;background:none;color:var(--ink-2);cursor:pointer}+.theme-btn .sun,:root[data-theme="dark"] .theme-btn .moon{display:none}+:root[data-theme="dark"] .theme-btn .sun{display:block}+.gh{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 16px;border-radius:999px;border:1px solid var(--line);background:var(--surface);text-decoration:none;font-size:15px;font-weight:600;white-space:nowrap}+.gh-c{color:var(--muted);font-variant-numeric:tabular-nums}+.foot{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px 24px;padding:36px 0 44px}+.foot-t{font-size:15px;color:var(--muted)}++/* one centered column: the head, the jump row, the entries and the suggestion */+.fx-page{width:min(1040px,calc(100% - 2 * var(--gut)));margin-inline:auto}+.fx-head{display:flex;flex-direction:column;align-items:center;text-align:center;padding-top:clamp(16px,4vw,48px)}+.pill{display:inline-flex;align-items:center;padding:8px 16px;border-radius:999px;background:var(--surface);border:1px solid var(--line);font-size:14px;font-weight:600;color:var(--ink-2)}+.h1{margin-top:22px;font-size:clamp(34px,5.2vw,64px);font-weight:800;line-height:1.04;letter-spacing:-.035em}+.fx-lede{margin-top:18px;max-width:640px;font-size:clamp(16px,1.4vw,19px);line-height:1.55;color:var(--ink-2)}+.fx-legal{margin-top:14px;max-width:640px;font-size:14px;line-height:1.55;color:var(--muted)}+.fx-jump{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:clamp(24px,3vw,36px)}+.fx-jump a{display:inline-flex;align-items:center;min-height:44px;padding:0 16px;border-radius:999px;border:1px solid var(--line);background:var(--surface);color:var(--ink-2);font-size:14px;font-weight:600;text-decoration:none;white-space:nowrap}++/* an entry: seen on, the title, what you see, the cards, the prompt and Copy prompt */+.fx{margin-top:clamp(36px,5vw,56px);padding-top:clamp(36px,5vw,56px);border-top:1px solid var(--line);scroll-margin-top:16px}+.fx-seen{display:flex;flex-wrap:wrap;align-items:center;column-gap:.35em;font-size:15px;color:var(--muted)}+.fx-seen a{display:inline-flex;align-items:center;min-width:44px;min-height:44px;color:var(--ink);font-weight:700;text-decoration:underline;text-decoration-color:var(--line);text-underline-offset:5px}+.fx h2{font-size:clamp(26px,3.2vw,36px);font-weight:800;line-height:1.1;letter-spacing:-.025em}+.fx-what{margin-top:14px;max-width:68ch;font-size:17px;line-height:1.65;color:var(--ink-2)}+.fx-what a{color:var(--ink);text-underline-offset:4px}+.fx-sub{margin:32px 0 14px;font-size:18px;font-weight:700;letter-spacing:-.01em}+.fx-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}+.fx-pbox{max-width:760px;padding:20px 22px;border-radius:20px;background:var(--surface);box-shadow:var(--shadow)}+.fx-prompt{font-size:17px;line-height:1.65;color:var(--ink)}+.fx-prompt mark{padding:1px 5px;border-radius:4px;background:color-mix(in srgb,var(--brand) 16%,transparent);color:var(--ink)}+.fx-toggle{display:none;align-items:center;min-height:44px;margin-top:4px;padding:0;border:0;background:none;color:var(--brand);font-size:15px;font-weight:700;cursor:pointer}+.copy{display:inline-flex;align-items:center;gap:10px;min-height:48px;margin-top:16px;padding:0 24px;border-radius:999px;border:0;background:var(--ink);color:var(--bg);font-size:16px;font-weight:700;cursor:pointer;transition:background .2s,color .2s}+.copy.done{background:var(--ok);color:#fff}++/* the cards: the home page's, with what each animation makes here on its preview and no Copy prompt */+.card{position:relative;display:flex;flex-direction:column;padding:10px;border-radius:20px;background:var(--surface);box-shadow:var(--shadow);transition:transform .35s var(--ease)}+.card:has(.title a:focus-visible){outline:3px solid var(--brand);outline-offset:3px}+.stage{position:relative;aspect-ratio:16/10;border-radius:12px;overflow:hidden;background:#08080a}+.tag{position:absolute;z-index:1;left:10px;top:10px;max-width:calc(100% - 20px);padding:5px 11px;border-radius:999px;background:rgba(255,255,255,.94);color:#16161b;font-size:12px;font-weight:700;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}+.meta{display:flex;flex-direction:column;flex:1;padding:14px 8px 6px}+.title{font-size:18px;font-weight:700;letter-spacing:-.01em;line-height:1.25}+.title a{text-decoration:none;outline:none}+.title a::after{content:"";position:absolute;inset:0;z-index:2;border-radius:20px}+.desc{flex:1;margin-top:6px;font-size:15px;line-height:1.5;color:var(--ink-2)}++/* Seen one we should add? */+.fx-more{display:flex;flex-direction:column;align-items:center;margin-top:clamp(36px,5vw,56px);padding-top:clamp(36px,5vw,56px);border-top:1px solid var(--line);text-align:center}+.fx-more h2{font-size:clamp(24px,2.6vw,30px);font-weight:800;line-height:1.15;letter-spacing:-.02em}+.fx-more p{margin-top:10px;max-width:560px;font-size:16px;line-height:1.55;color:var(--ink-2)}+.fx-suggest{display:inline-flex;align-items:center;justify-content:center;min-height:48px;margin-top:18px;padding:0 24px;border-radius:999px;border:1.5px solid var(--ink);font-size:16px;font-weight:700;text-decoration:none;transition:background .2s,color .2s}+.fx-more .fx-note{margin-top:18px;font-size:14px;color:var(--muted)}++/* the message after a copy: the home page's */+.toast{position:fixed;z-index:60;left:50%;bottom:24px;display:flex;align-items:center;gap:10px;min-height:52px;width:max-content;max-width:calc(100% - 32px);padding:0 18px;border-radius:16px;background:var(--ink);color:var(--bg);font-size:15px;font-weight:600;box-shadow:0 12px 32px rgba(22,22,27,.28);opacity:0;transform:translate(-50%,16px);pointer-events:none;transition:opacity .25s,transform .25s var(--ease)}+.toast.show{opacity:1;transform:translate(-50%,0)}+.toast .ok{display:inline-grid;place-items:center;width:28px;height:28px;flex:none;border-radius:50%;background:#1f9d57;color:#fff}+.toast .ok .i{width:16px;height:16px}++@media(hover:hover){+ .lnk:hover,.icon-btn:hover{color:var(--ink);background:var(--line-2)}+ .gh:hover,.fx-jump a:hover{border-color:var(--ink);color:var(--ink)}+ .fx-seen a:hover{text-decoration-color:currentColor}+ .card:hover{transform:translateY(-4px);box-shadow:var(--shadow-2)}+ .card:hover .pv{transform:scale(1.04)}+ .copy:hover{background:var(--brand);color:var(--bg)}+ .copy.done:hover{background:var(--ok);color:#fff}+ .fx-suggest:hover{background:var(--ink);color:var(--bg)}+}+/* two cards across below 761px; from 760px down the GitHub button is a round star, as on the home page */+@media(max-width:760px){+ .fx-cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}+ .gh{position:relative;width:44px;padding:0;justify-content:center;gap:0}+ .gh-t{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}+ .gh-c{display:none}+}+/* phones */+@media(max-width:600px){+ .top{min-height:60px}+ .top .nav .lnk{display:none}+ .brand{gap:10px;font-size:15px}+ .mark{width:28px;height:28px}+ .pill{padding:7px 13px;font-size:13px}+ .fx-jump{flex-wrap:nowrap;justify-content:flex-start;width:calc(100% + 2 * var(--gut));margin-inline:calc(-1 * var(--gut));padding-inline:var(--gut);overflow-x:auto;scrollbar-width:none}+ .fx-jump a{flex:none}+ .fx-what{font-size:16px;line-height:1.6}+ .fx-what a{padding-block:14px} /* a link inside a sentence: its touch area grows to 44px without moving the lines */+ .fx-pbox{padding:16px 18px}+ .fx-prompt{font-size:16px;line-height:1.6}+ .fx-prompt.is-clamped{display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;overflow:hidden}+ .fx-toggle{display:inline-flex}+ .copy{width:100%;justify-content:center}+ .card{padding:6px;border-radius:16px}+ .title a::after{border-radius:16px}+ .stage{border-radius:10px}+ .tag{left:6px;top:6px;max-width:calc(100% - 12px);padding:3px 8px;font-size:11px;white-space:normal} /* two cards across: a long label takes a second line instead of being cut */+ .meta{padding:10px 6px 4px}+ .title{font-size:15px}+ .desc{flex:none;margin-top:4px;font-size:13px;line-height:1.45;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}+ .fx-suggest{width:100%}+ .foot{flex-direction:column;align-items:flex-start}+}+@media(max-width:360px){.tag{left:5px;top:5px;max-width:calc(100% - 10px);padding:3px 6px;font-size:10px}}+@media(max-width:359px){.gh{display:none}}+/* reduced motion: the cards do not lift and the message fades in place (the previews hold still: see the block below) */+@media(prefers-reduced-motion:reduce){+ .card,.card:hover,.card:hover .pv{transform:none;transition:none}+ .toast{transform:translate(-50%,0);transition:opacity .25s}+}++/* ── previews: written by tools/make-famous.mjs from the home page; run it again, never edit by hand ── */+/* the base: each category's accent color, the preview box, and its animations paused unless its card plays */+.c1{--accent:var(--c1)}+.c2{--accent:var(--c2)}+.c3{--accent:var(--c3)}+.c4{--accent:var(--c4)}+.c5{--accent:var(--c5)}+.c6{--accent:var(--c6)}+.c7{--accent:var(--c7)}+.pv{position:absolute;inset:0;width:100%;height:100%;transition:transform .6s var(--ease);--ink:#f4f4f2;--ink-dim:#adadb2;--muted:#77777e;--line:rgba(255,255,255,.085)}+.pv *{will-change:transform}+.card:not(.playing) .pv .anim,.card:not(.playing) .pv .anim::before,.card:not(.playing) .pv .anim::after{animation-play-state:paused!important}+@media(prefers-reduced-motion:reduce){.pv .anim,.pv .anim::before,.pv .anim::after{animation-play-state:paused!important}}+/* ── end of previews ── */+</style>+</head>+<body>+<a class="skip" href="#stripe-ribbon">Skip to the first effect</a>+<header class="wrap top" id="top">+ <a class="brand" href="../"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><circle class="ring" cx="11.16" cy="20.84" r="6.1"/><circle class="ring" cx="15.12" cy="16.88" r="6.1"/><circle class="ring" cx="18.51" cy="13.49" r="6.1"/><circle class="ball" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>+ <nav class="nav" aria-label="Site">+ <a class="lnk" href="../?view=all">Browse all</a>+ <a class="lnk" href="./" aria-current="page">Famous effects</a>+ <button type="button" class="icon-btn theme-btn" id="theme-toggle" aria-label="Switch between light and dark">+ <svg class="i moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>+ <svg class="i sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>+ </button>+ <a class="gh" id="gh-stars" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener"><svg class="i" 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 class="gh-t">GitHub</span> <span class="gh-c" id="gh-star-count"></span></a>+ </nav>+</header>++<main class="fx-page">+ <div class="fx-head">+ <p class="pill">12 effects from well-known websites</p>+ <h1 class="h1">Famous effects</h1>+ <p class="fx-lede">Effects people admire on well-known websites, the handbook animations that make something similar, and a prompt to build your own.</p>+ <p class="fx-legal">The Animation Handbook is not connected to any of these sites or their owners, and none of them has reviewed or approved this page. Each effect is described in our own words and shown only with the handbook's own demos.</p>+ </div>+ <nav class="fx-jump" aria-label="Effects on this page">+ </nav>++ <section class="fx-more" aria-labelledby="fx-more-t">+ <h2 id="fx-more-t">Seen one we should add?</h2>+ <p>Seen an effect on a well-known site that you want explained?</p>+ <a class="fx-suggest" href="https://github.com/matinmonshizadeh/animation-handbook/issues/new?template=famous_effect.yml" target="_blank" rel="noopener">Suggest it on GitHub<span class="sr"> (opens in a new tab)</span></a>+ <p class="fx-note">Each entry was checked by hand on the date shown; a site may have changed since.</p>+ </section>+</main>++<footer class="wrap foot">+ <a class="brand" href="../"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><circle class="ring" cx="11.16" cy="20.84" r="6.1"/><circle class="ring" cx="15.12" cy="16.88" r="6.1"/><circle class="ring" cx="18.51" cy="13.49" r="6.1"/><circle class="ball" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>+ <p class="foot-t">Web animations with live demos and copyable prompts.</p>+ <nav class="nav" aria-label="Footer"><a class="lnk" href="https://github.com/matinmonshizadeh/animation-handbook" target="_blank" rel="noopener">GitHub</a><a class="lnk" href="#top">Back to top</a></nav>+</footer>+<div class="toast" id="toast" role="status" aria-live="polite"><span class="ok" aria-hidden="true"><svg class="i" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span><span class="toast-t"></span></div>++<script>+// The GitHub star count, as on the home page: kept for five minutes, so the page asks GitHub at most once in that time.+(function loadStars(){+ const KEY='gh-star-count',TTL=5*60*1000;+ function show(n){const el=document.getElementById('gh-star-count');if(el)el.textContent='★ '+Number(n).toLocaleString();}+ try{const c=localStorage.getItem(KEY);if(c){const{count,ts}=JSON.parse(c);if(Date.now()-ts<TTL){show(count);return;}}}catch(e){}+ fetch('https://api.github.com/repos/matinmonshizadeh/animation-handbook')+ .then(r=>r.ok?r.json():Promise.reject()).then(d=>{show(d.stargazers_count);+ try{localStorage.setItem(KEY,JSON.stringify({count:d.stargazers_count,ts:Date.now()}));}catch(e){}}).catch(()=>{});+})();++(function(){const btn=document.getElementById('theme-toggle');if(!btn)return;+ btn.addEventListener('click',()=>{const next=document.documentElement.dataset.theme==='dark'?'light':'dark';+ setTheme(next);try{localStorage.setItem('ah-theme',next);}catch(e){}});})();++const reduce=matchMedia('(prefers-reduced-motion:reduce)').matches;++// Opened from disk, a link to a folder shows the browser's list of its files, so there every link to a folder names its+// index.html (the logo, Browse all, this page's own link and the cards), as on the home page.+if(location.protocol==='file:')document.querySelectorAll('a[href]').forEach(a=>{+ const href=a.getAttribute('href'),cut=href.search(/[?#]/),path=cut<0?href:href.slice(0,cut);+ if(/\/$/.test(path)&&!/^(?:\/|[a-z][a-z0-9+.-]*:)/i.test(path))a.setAttribute('href',path+'index.html'+href.slice(path.length));+});++// ── previews: written by tools/make-famous.mjs from the home page; run it again, never edit by hand ──+const PREVIEWS={+};+// ── end of previews ──++// Each card shows its animation's preview from the home page. It plays while the card is on screen (on phones, while the card+// is in the middle of the screen) and while the card holds keyboard focus; under reduced motion it holds one still, clear frame+// (the point the home page holds it at).+const io='IntersectionObserver' in window?new IntersectionObserver(es=>es.forEach(en=>en.target.classList.toggle('playing',en.isIntersecting)),+ matchMedia('(hover:hover)').matches?{threshold:.2}:{rootMargin:'-34% 0px -34% 0px'}):null;+function hold(card,still){+ const anims=card.querySelector('.pv').getAnimations({subtree:true});+ if(!anims.length)return;+ const at=still*anims[0].effect.getTiming().duration;+ for(const a of anims)a.currentTime=at;+}+document.querySelectorAll('.fx .card[data-slug]').forEach(card=>{+ const p=PREVIEWS[card.dataset.slug],pv=card.querySelector('.pv');+ if(!p||!pv)return;+ pv.classList.add('pv-'+p.pv);+ pv.innerHTML=p.markup;+ if(reduce){hold(card,p.still);return;}+ card.addEventListener('focusin',()=>card.classList.add('playing'));+ if(io)io.observe(card);else card.classList.add('playing');+});++// A link to an entry (the jump row, the skip link) brings the entry into view and gives its heading keyboard focus; under+// reduced motion it jumps instead of gliding. A click with Ctrl, Cmd, Shift or Alt, or another button, is left to the browser.+document.addEventListener('click',e=>{+ const a=e.target.closest('a[href^="#"]');+ if(!a||e.button||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;+ const entry=document.getElementById(a.getAttribute('href').slice(1));+ if(!entry||!entry.matches('section.fx'))return;+ e.preventDefault();+ entry.scrollIntoView({behavior:reduce?'auto':'smooth',block:'start'});+ entry.querySelector('h2').focus({preventScroll:true});+ try{history.pushState(null,'','#'+entry.id);}catch(err){}+});++// The prompts: on phones each shows five lines and "Show the full prompt", as on the animation pages.+document.querySelectorAll('.fx-prompt').forEach(p=>{+ p.id=p.closest('section.fx').id+'-prompt';+ p.classList.add('is-clamped');+ const more=document.createElement('button');+ more.type='button';more.className='fx-toggle';+ more.setAttribute('aria-controls',p.id);more.setAttribute('aria-expanded','false');+ more.textContent='Show the full prompt';+ more.addEventListener('click',()=>{const open=!p.classList.toggle('is-clamped');more.setAttribute('aria-expanded',String(open));more.textContent=open?'Show less':'Show the full prompt';});+ p.after(more);+});++// Copy prompt copies the prompt as shown, brackets included. It reads "Copied" for about two seconds and the home page's+// message shows; where the browser refuses the clipboard, the prompt is selected and the button asks for the copy keys.+// Only the icon and the label's words change: the label is a live region, so a screen reader announces the change, and the+// button's name always starts with what it shows and names its entry.+const ICON_COPY='<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg>';+const ICON_DONE='<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';+const KEYS=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent)?'Press ⌘C to copy':'Press Ctrl+C to copy';+const toastEl=document.getElementById('toast'),toastText=toastEl.querySelector('.toast-t');let toastTimer=0,toastClear=0;+function toast(message){+ clearTimeout(toastTimer);clearTimeout(toastClear);+ toastText.textContent=message;+ toastEl.classList.add('show');+ toastTimer=setTimeout(()=>{toastEl.classList.remove('show');toastClear=setTimeout(()=>{toastText.textContent='';},300);},2400);+}+function copyState(btn,kind){+ const title=btn.closest('section.fx').querySelector('h2').textContent;+ clearTimeout(btn._timer);+ btn.classList.toggle('done',kind==='done');+ btn.querySelector('.i').outerHTML=kind==='done'?ICON_DONE:ICON_COPY;+ const label=kind==='done'?'Copied':kind==='keys'?KEYS:'Copy prompt';+ btn.querySelector('.copy-l').textContent=label;+ btn.setAttribute('aria-label',kind==='done'?'Copied the prompt for '+title:kind==='keys'?KEYS+': the prompt for '+title+' is selected':'Copy prompt for '+title);+ if(kind)btn._timer=setTimeout(()=>copyState(btn,''),kind==='done'?2000:4000);+}+document.querySelectorAll('.fx .copy').forEach(btn=>btn.addEventListener('click',()=>{+ const prompt=btn.closest('section.fx').querySelector('.fx-prompt');+ const text=prompt.textContent.replace(/\s+/g,' ').trim();+ const clip=navigator.clipboard;+ (clip&&clip.writeText?clip.writeText(text):Promise.reject(new Error('no clipboard'))).then(()=>{+ copyState(btn,'done');+ toast('Prompt copied. Paste it into your AI assistant.');+ },()=>{+ const range=document.createRange();+ range.selectNodeContents(prompt);+ const sel=getSelection();+ sel.removeAllRanges();+ sel.addRange(range);+ copyState(btn,'keys');+ });+}));+</script>+</body>+</html>diff --git a/tests/famous.test.js b/tests/famous.test.jsindex 28a05928..53f2dc3d 100644--- a/tests/famous.test.js+++ b/tests/famous.test.js@@ -94,3 +94,150 @@ test('make-famous: the blocks go between their marker lines, a second run changeassert.throws(() => replaceBetween('no markers here', CSS_START, CSS_END, 'x'), /must each be there once/);assert.throws(() => replaceBetween(CSS_START + CSS_END + CSS_START, CSS_START, CSS_END, 'x'), /must each be there once/);});++// ---------- The page: its frame ----------+const FILE = path.join(ROOT, 'famous', 'index.html');+// A file's text with Windows line endings read as plain ones: a checkout may hold either.+const read = f => fs.readFileSync(f, 'utf8').replace(/\r\n/g, '\n');+const PAGE = read(FILE);+const HOME = read(path.join(ROOT, 'index.html'));+const LIVE = 'https://matinmonshizadeh.github.io/animation-handbook/';+const REPO = 'https://github.com/matinmonshizadeh/animation-handbook';+const TEMPLATE = `${REPO}/issues/new?template=famous_effect.yml`;+const TITLE = 'Famous effects — Animation Handbook';+const LEDE = 'Effects people admire on well-known websites, the handbook animations that make something similar, and a prompt to build your own.';+const LEGAL = "The Animation Handbook is not connected to any of these sites or their owners, and none of them has reviewed or approved this page. Each effect is described in our own words and shown only with the handbook's own demos.";+// The sites the page may name (the twelve entries and the reserves): none belongs in its title or description.+const SITE_NAMES = ['Stripe', 'Apple', 'Lando Norris', 'Linear', 'Wikipedia', 'ChatGPT', 'OpenAI', 'x.com', 'Spotify', 'YouTube', 'Pudding', 'Medium', 'Rockstar', 'Cursor'];+const count = (s, sub) => s.split(sub).length - 1;+// The part of s from the first `from` up to the next `to` after it ('' when `from` is missing).+const between = (s, from, to) => {+ const start = s.indexOf(from);+ if (start < 0) return '';+ const end = s.indexOf(to, start + from.length);+ return s.slice(start, end < 0 ? undefined : end);+};+const decode = s => s.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');+// The words a piece of markup shows: tags dropped, entities decoded, white space squeezed (as the page's Copy prompt reads it).+const textOf = html => decode(html.replace(/<[^>]*>/g, '')).replace(/\s+/g, ' ').trim();+const meta = attr => { const m = PAGE.match(new RegExp(`<meta ${attr} content="([^"]*)">`)); return m && decode(m[1]); };+// What a visitor reads: the page without its scripts and styles.+const MARKUP = PAGE.replace(/<script\b[\s\S]*?<\/script>/g, '').replace(/<style\b[\s\S]*?<\/style>/g, '');+const escapeRe = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+// Whether a link or source of famous/index.html names a file of the repository (a folder stands for its index.html).+const isRepoFile = ref => {+ const bare = ref.replace(/[?#].*$/, '');+ if (/^[a-z][a-z0-9+.-]*:/i.test(bare) || bare.startsWith('/')) return false;+ const file = path.resolve(ROOT, 'famous', bare || '.');+ return fs.existsSync(bare === '' || bare.endsWith('/') ? path.join(file, 'index.html') : file);+};++test('famous/index.html: one title and one description for search and social sites, with no company name in them', () => {+ assert.equal(count(PAGE, '<title>'), 1, 'one title');+ assert.ok(PAGE.includes(`<title>${TITLE}</title>`), 'the title');+ 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);+ assert.ok(PAGE.includes('<h1 class="h1">Famous effects</h1>'), 'the heading');+ assert.ok(PAGE.includes(`<p class="fx-lede">${LEDE}</p>`), 'the lede under it');+ assert.match(PAGE, /<p class="pill">\d+ effects from well-known websites<\/p>/, 'the pill');+ for (const name of SITE_NAMES) assert.ok(!new RegExp(`\\b${escapeRe(name)}\\b`, 'i').test(`${TITLE} ${LEDE}`), `no "${name}" in the title or description`);+});++test('famous/index.html: canonical and og:url are its live address, and it shares the site\'s picture', () => {+ assert.ok(PAGE.includes(`<link rel="canonical" href="${LIVE}famous/">`), 'canonical');+ assert.equal(meta('property="og:url"'), `${LIVE}famous/`);+ for (const attr of ['property="og:image"', 'name="twitter:image"']) assert.equal(meta(attr), `${LIVE}og-image.png`, attr);+});++test('the top bar is the home page\'s, with Famous effects marked as this page', () => {+ const bar = between(PAGE, '<header class="wrap top" id="top">', '</header>');+ for (const part of ['<a class="brand" href="../">', '<a class="lnk" href="../?view=all">Browse all</a>', '<a class="lnk" href="./" aria-current="page">Famous effects</a>',+ '<button type="button" class="icon-btn theme-btn" id="theme-toggle" aria-label="Switch between light and dark">',+ `<a class="gh" id="gh-stars" href="${REPO}" target="_blank" rel="noopener">`]) assert.ok(bar.includes(part), part);+ assert.equal(count(MARKUP, 'aria-current='), 1, 'one current page');+});++test('the light and dark colors and the theme switch are the home page\'s', () => {+ const block = (html, selector) => {+ const css = between(html, '<style>', '</style>'), at = css.indexOf(`${selector}{`);+ assert.ok(at >= 0, selector);+ return css.slice(at, css.indexOf('}', at) + 1).replace(/\s+/g, '');+ };+ for (const selector of [':root', ':root[data-theme="dark"]']) assert.equal(block(PAGE, selector), block(HOME, selector), selector);+ assert.ok(PAGE.includes(HOME.match(/function setTheme\(t\)\{[^\n]*\}/)[0]), 'the same setTheme as the home page');+});++test('the not-connected line is on the page once, word for word, above the jump row and every entry', () => {+ assert.equal(count(PAGE, LEGAL), 1, 'once');+ assert.ok(PAGE.includes(`<p class="fx-legal">${LEGAL}</p>`), 'in its own paragraph');+ const at = PAGE.indexOf(LEGAL);+ assert.ok(at < PAGE.indexOf('<nav class="fx-jump"'), 'above the jump row');+ assert.ok(PAGE.indexOf('<section class="fx"') < 0 || at < PAGE.indexOf('<section class="fx"'), 'above the first entry');+});++test('the page loads nothing from elsewhere, uses only the site\'s font in its own style and shows no code', async () => {+ const { CSS_START, CSS_END } = await tool();+ for (const bad of ['<img', '<video', '<iframe', '<picture', '<object', '<embed', '@import', 'url(http']) assert.ok(!PAGE.includes(bad), bad);+ assert.ok(!/demo-page\.(css|js)/.test(PAGE), 'it links neither shared file');+ for (const [, src] of PAGE.matchAll(/\ssrc="([^"]*)"/g)) assert.ok(isRepoFile(src), `src ${src}`);+ for (const [tag] of PAGE.matchAll(/<link\b[^>]*>/g)) {+ if (!/\srel="(stylesheet|icon|apple-touch-icon)"/.test(tag)) continue;+ const href = tag.match(/\shref="([^"]*)"/)[1];+ assert.ok(isRepoFile(href), `link ${href}`);+ }+ const css = between(PAGE, '<style>', '</style>').replace(/url\(\s*(["'])data:[\s\S]*?\1\s*\)/g, '');+ for (const [, ref] of css.matchAll(/url\(\s*['"]?([^'")\s]+)/g)) assert.ok(isRepoFile(ref), `url(${ref})`);+ const own = css.slice(0, css.indexOf(CSS_START)) + css.slice(css.indexOf(CSS_END));+ for (const [, family] of own.matchAll(/font-family:([^;}]+)/g)) assert.match(family.trim(), /^(var\(--disp\)|var\(--text\)|'Schibsted Grotesk')$/, `font-family:${family}`);+ assert.ok(!/`|<code|<pre/.test(MARKUP), 'no backtick, <code> or <pre> outside <script> and <style>');+});++test('the only links that leave the site are the entries\' sites, the GitHub repository and its issue template, each in a new tab', () => {+ const sites = new Set([...PAGE.matchAll(/<p class="fx-seen">Seen on <a href="([^"]+)"/g)].map(m => m[1]));+ for (const [tag, href] of PAGE.matchAll(/<a\b[^>]*\shref="(https?:[^"]*)"[^>]*>/g)) {+ assert.ok(href === REPO || href === TEMPLATE || sites.has(href), `a link that leaves the site: ${href}`);+ assert.match(tag, /\starget="_blank" rel="noopener"/, `${href} opens in a new tab`);+ }+});++test('every link inside the site opens a file of the repository, and from disk a folder link opens its index.html', () => {+ for (const [, href] of PAGE.matchAll(/<a\b[^>]*\shref="([^"]*)"/g)) {+ if (/^https?:/.test(href) || href.startsWith('#')) continue;+ assert.ok(isRepoFile(href), href);+ }+ assert.ok(PAGE.includes("if(location.protocol==='file:')document.querySelectorAll('a[href]').forEach(a=>{"), 'opened from disk, folder links name index.html');+});++test('the footer is the home page\'s, without the count', () => {+ const foot = between(PAGE, '<footer class="wrap foot">', '</footer>');+ assert.ok(foot.includes('<p class="foot-t">Web animations with live demos and copyable prompts.</p>'), 'its line, with no number');+ assert.ok(foot.includes(`<a class="lnk" href="${REPO}" target="_blank" rel="noopener">GitHub</a><a class="lnk" href="#top">Back to top</a>`), 'its links');+ assert.ok(!/\d/.test(textOf(foot)), 'no number in the footer');+});++test('the page script copies, falls back to the copy keys, shortens prompts on phones and shows the message, in the words of the animation pages and the home page', () => {+ const script = [...PAGE.matchAll(/<script>([\s\S]*?)<\/script>/g)].map(m => m[1]).join('\n');+ const shared = read(path.join(ROOT, 'assets', 'js', 'demo-page.js'));+ for (const words of ['Show the full prompt', 'Show less', 'Press ⌘C to copy', 'Press Ctrl+C to copy']) {+ assert.ok(script.includes(`'${words}'`), `the page says "${words}"`);+ assert.ok(shared.includes(`'${words}'`), `as the animation pages do: "${words}"`);+ }+ assert.ok(script.includes("toast('Prompt copied. Paste it into your AI assistant.')") && HOME.includes("toast('Prompt copied. Paste it into your AI assistant.')"), 'the home page\'s message');+ for (const words of ["'Copy prompt'", "'Copied'"]) assert.ok(script.includes(words), words);+ assert.ok(PAGE.includes('<div class="toast" id="toast" role="status" aria-live="polite">'), 'the message box');+});++test('Seen one we should add? opens the Famous effect issue template, which asks for the site and what you see in your own words, with no screenshots or code', () => {+ assert.ok(PAGE.includes(`<a class="fx-suggest" href="${TEMPLATE}" target="_blank" rel="noopener">Suggest it on GitHub<span class="sr"> (opens in a new tab)</span></a>`), 'the Suggest link');+ assert.ok(PAGE.includes('<p class="fx-note">Each entry was checked by hand on the date shown; a site may have changed since.</p>'), 'the note on dates');+ const yml = read(path.join(ROOT, '.github', 'ISSUE_TEMPLATE', 'famous_effect.yml'));+ assert.match(yml, /^name: Famous effect$/m, 'its name');+ const field = id => yml.split('\n - type: ').find(part => part.includes(`\n id: ${id}\n`)) || '';+ for (const id of ['address', 'what']) assert.match(field(id), /\n {4}validations:\n {6}required: true/, `${id} is required`);+ assert.match(yml, /no screenshots, videos or code from the site/i, 'no screenshots or code from the site');+});++test('the two preview blocks are what tools/make-famous.mjs writes from the home page now', async () => {+ const { buildFamous } = await tool();+ assert.ok(buildFamous(ROOT)['famous/index.html'] === PAGE, `famous/index.html is out of date: run ${TOOL}`);+});