-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
416 lines (390 loc) · 23.7 KB
/
Copy pathindex.html
File metadata and controls
416 lines (390 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FX Lab — a standing exhibition of 99 zero-dependency web effects</title>
<meta name="description" content="99 paste-anywhere web effects (WebGL2 / Canvas2D / DOM), hung like artworks. Find one by vibe, copy a self-contained snippet.">
<!-- LLM/agent discovery: a slim, vibe-first catalog lives at /llms.txt -->
<link rel="alternate" type="text/markdown" href="./llms.txt">
<meta name="llms-txt" content="./llms.txt">
<link rel="canonical" href="https://fx.rosuh.me/">
<!-- Social / Open Graph + Twitter cards (absolute URLs required by crawlers) -->
<meta property="og:type" content="website">
<meta property="og:site_name" content="FX Lab">
<meta property="og:title" content="FX Lab — 99 zero-dependency web effects">
<meta property="og:description" content="99 paste-anywhere web effects — WebGL2 shaders, Canvas-2D & DOM. Find one by vibe, copy a self-contained snippet. No build, no npm. MIT.">
<meta property="og:url" content="https://fx.rosuh.me/">
<meta property="og:image" content="https://fx.rosuh.me/og.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="A wall of live FX Lab web effects with the FX Lab wordmark">
<meta property="og:locale" content="en_US">
<meta property="og:locale:alternate" content="zh_CN">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="FX Lab — 99 zero-dependency web effects">
<meta name="twitter:description" content="99 paste-anywhere web effects (WebGL2 / Canvas2D / DOM). Find one by vibe, copy a self-contained snippet.">
<meta name="twitter:image" content="https://fx.rosuh.me/og.png">
<meta name="theme-color" content="#0c0a0a">
<link rel="icon" href="./favicon.svg" type="image/svg+xml">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root{
/* darkened-gallery palette — warm ink wall, bone placard paper, one vermilion mark. */
--ink:#0c0a0a; --ink-2:#141010; --ink-3:#1c1714;
--bone:#ECE5D8; --bone-dim:#9c9488;
--line:#2a2320; --flare:#FF5638; --flare-soft:rgba(255,86,56,.42);
--flare-wash:rgba(255,86,56,.06); /* ponytail: folded from body::before inline */
--canvas-bg:#000;
--display:'Bricolage Grotesque', system-ui, sans-serif;
--mono:'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
--shell:1240px;
}
*{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
margin:0; background:var(--ink); color:var(--bone);
font-family:var(--display); font-optical-sizing:auto;
-webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}
/* a single soft wash from the top — gallery wall-wash lighting, no stripes, no noise. */
body::before{
content:''; position:fixed; inset:0; z-index:-1; pointer-events:none;
background:radial-gradient(130% 80% at 50% -12%, var(--flare-wash), transparent 58%);
}
a{ color:inherit; }
/* on-brand focus ring — vermilion, 2px, offset so it clears the element edge */
a:focus-visible, button:focus-visible{ outline:2px solid var(--flare); outline-offset:3px; border-radius:2px; }
/* ---------- entrance wall ---------- */
.entrance{ max-width:var(--shell); margin:0 auto; padding:clamp(40px,7vw,92px) clamp(20px,5vw,56px) 0; }
.entrance-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:clamp(24px,5vw,56px); flex-wrap:wrap; }
.wordmark{
margin:0; color:var(--bone); font-weight:800;
font-size:clamp(58px,13vw,170px); line-height:.84; letter-spacing:-.055em;
}
.wordmark .lab{ color:var(--flare); }
.colophon{ display:flex; flex-direction:column; align-items:flex-end; gap:16px; padding-top:10px; }
.catalog{ display:flex; gap:20px; flex-wrap:wrap; justify-content:flex-end; }
.catalog a{
font-family:var(--mono); font-size:11.5px; letter-spacing:.02em; color:var(--bone-dim);
text-decoration:none; padding:11px 4px 11px; border-bottom:1px solid var(--line);
display:inline-flex; align-items:center; min-height:44px; /* a11y: touch target */
transition:color .25s ease, border-color .25s ease;
}
.catalog a:hover{ color:var(--flare); border-color:var(--flare-soft); }
.catalog a.gh{ gap:7px; color:var(--bone); border-color:var(--flare-soft); } /* the repo: the primary entry */
.catalog a.gh svg{ transition:transform .25s ease; }
.catalog a.gh:hover{ color:var(--flare); }
.catalog a.gh:hover svg{ transform:rotate(-7deg) scale(1.08); }
/* pill toggle — pill is the border, buttons are the cells */
.lang{ display:inline-flex; border:1px solid var(--line); border-radius:999px; overflow:hidden; }
.lang button{
cursor:pointer; background:transparent; border:0; color:var(--bone-dim);
font-family:var(--mono); font-size:11px; letter-spacing:.04em;
padding:0 15px; min-height:44px; /* a11y: touch target */
transition:color .2s ease, background .2s ease;
}
.lang button:not(.active):hover{ color:var(--bone); }
.lang button.active{ background:var(--flare); color:var(--ink); }
.sub{
margin:clamp(30px,4.5vw,50px) 0 0; max-width:60ch;
font-size:clamp(15px,1.8vw,20px); line-height:1.55; color:var(--bone-dim); font-weight:400;
}
.sub::before{
content:''; display:block; width:46px; height:2px; background:var(--flare);
margin-bottom:clamp(20px,2.5vw,28px);
}
/* C-graft: quiet mono inventory strip under the hero sub-line */
.inventory{
margin:clamp(14px,1.8vw,20px) 0 0; font-family:var(--mono); font-size:11.5px;
letter-spacing:.04em; color:var(--bone-dim); opacity:.72;
}
.gap{ height:clamp(54px,9vw,120px); }
/* ---------- the wall ---------- */
main{ max-width:var(--shell); margin:0 auto; padding:0 clamp(20px,5vw,56px) clamp(80px,12vw,160px); }
.room{ margin-top:clamp(72px,11vw,150px); }
.room:first-child{ margin-top:0; }
.room-head{
display:flex; align-items:baseline; justify-content:space-between; gap:24px;
padding-bottom:clamp(18px,2.4vw,26px); margin-bottom:clamp(30px,4.5vw,52px);
border-bottom:1px solid var(--line);
}
.room-title{
margin:0; color:var(--bone); font-weight:600; line-height:1;
font-size:clamp(28px,4.6vw,52px); letter-spacing:-.04em;
}
.tally{ font-family:var(--mono); font-size:13px; color:var(--bone-dim); letter-spacing:.16em; white-space:nowrap; }
.wall{
display:grid; gap:clamp(20px,2.7vw,42px);
grid-template-columns:repeat(auto-fill, minmax(min(100%,320px), 1fr));
}
/* ---------- each piece: a matted, mounted artwork ---------- */
.piece{
margin:0; background:var(--ink-2); border:1px solid var(--line); border-radius:3px;
overflow:hidden; display:flex; flex-direction:column;
transition:border-color .35s ease, transform .35s ease;
}
.piece:hover{ border-color:var(--flare-soft); transform:translateY(-4px); }
.fx{
position:relative; height:clamp(208px,24vw,300px); background:var(--canvas-bg);
display:flex; align-items:center; justify-content:center; overflow:hidden;
}
.fx canvas{ display:block; width:100%; height:100%; }
/* C-graft: feature tile spans full grid width, fx bleeds edge-to-edge without border-radius */
@media (min-width:760px){
.piece.feature{ grid-column:1 / -1; border-radius:0; border-left:0; border-right:0; }
.piece.feature .fx{ height:clamp(340px,38vw,540px); }
}
/* placard — the small museum label. always legible; hover only sharpens it. */
.placard{
position:relative; padding:18px 20px 22px; border-top:1px solid var(--line);
display:flex; flex-direction:column; gap:9px;
}
.placard::before{
content:''; position:absolute; left:20px; top:-1px; height:2px; width:0;
background:var(--flare); transition:width .4s ease;
}
.piece:hover .placard::before{ width:36px; }
.placard-row{ display:flex; align-items:baseline; gap:16px; }
.name{
flex:1; min-width:0; margin:0; color:var(--bone); font-weight:600;
font-size:clamp(18px,1.5vw,21px); line-height:1.16; letter-spacing:-.02em;
}
.name small{
display:block; margin-top:4px; font-family:var(--mono); font-weight:400;
font-size:11.5px; letter-spacing:.01em; color:var(--bone-dim);
}
.medium{
flex:none; font-family:var(--mono); font-size:10.5px; letter-spacing:.06em;
color:var(--bone-dim); white-space:nowrap; transition:color .25s ease;
}
.piece:hover .medium{ color:var(--flare); }
.summary{ margin:0; max-width:48ch; color:var(--bone-dim); font-size:14px; line-height:1.5; font-weight:400; }
/* a11y: touch target on per-tile detail link */
.detail{
align-self:flex-start; font-family:var(--mono); font-size:11.5px;
color:var(--bone-dim); text-decoration:none; border-bottom:1px solid transparent;
display:inline-flex; align-items:center; min-height:44px; /* a11y: touch target */
transition:color .25s ease, border-color .25s ease;
}
.piece:hover .detail, .detail:hover{ color:var(--flare); border-color:var(--flare-soft); }
/* ---------- colophon plate ---------- */
footer{
max-width:var(--shell); margin:0 auto; padding:34px clamp(20px,5vw,56px) 60px;
border-top:1px solid var(--line); color:var(--bone-dim);
font-family:var(--mono); font-size:12px; letter-spacing:.05em;
}
/* ---------- loading overlay — dogfoods our own 'spinners' (Loaders) effect ---------- */
#loader{
position:fixed; inset:0; z-index:50; background:var(--ink);
display:flex; flex-direction:column; align-items:center; justify-content:center; gap:22px;
transition:opacity .5s ease;
}
#loader.hide{ opacity:0; pointer-events:none; }
#loader .loader-fx{ width:180px; height:130px; }
#loader .loader-fx canvas{ width:100%; height:100%; display:block; }
#loader .loader-text{ color:var(--bone-dim); font-family:var(--mono); font-size:12.5px; letter-spacing:.1em; }
#loader .loader-text b{ color:var(--flare); font-weight:500; }
@media (prefers-reduced-motion: reduce){
*, *::before, *::after{ transition:none !important; animation:none !important; }
.piece:hover{ transform:none; }
.placard::before{ width:36px; } /* static registration tick */
}
</style>
<!-- Mixpanel analytics. The project token is public by design (same as GA/Plausible) — it only identifies which project events belong to; it grants no read access to dashboard data. -->
<script>
(function(f,b){if(!b.__SV){var e,g,i,h;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b){var c=b.split(".");2==c.length&&(b=b[c[0]],a[c[0]]=a[c[0]]||{},a=a[c[0]])}b._q.push({a:d});f("track");f("identify");f("reset");f("register");f("alias");f("people.set");f("people.increment");f("track_charge");f("append");b._i[d]={};a&&"function"==typeof a&&(b._i[d]=a)};b.__SV=1.2;e=f.createElement("script");e.type="text/javascript";e.async=!0;e.src="https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";g=f.getElementsByTagName("script")[0];g.parentNode.insertBefore(e,g)}})(document,window.mixpanel||[]);
mixpanel.init("72970b4dccaded033cafffc4bb48e196", { debug: false, track_pageview: true, persistence: "localStorage" });
</script>
</head>
<body>
<div id="loader"><div class="loader-fx"></div><div class="loader-text" id="loader-text"></div></div>
<header class="entrance">
<div class="entrance-top">
<h1 class="wordmark">FX <span class="lab">Lab</span></h1>
<div class="colophon">
<nav class="catalog" aria-label="External resources">
<a class="gh" href="https://github.com/rosuH/fx-lab" target="_blank" rel="noopener" aria-label="View source on GitHub"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8 8 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>GitHub</a>
<a href="./llms.txt">llms.txt</a>
<a href="./llms.zh.txt">llms.zh.txt</a>
<a href="./fx-index.json">fx-index.json</a>
</nav>
<!-- a11y: aria-pressed set by applyLang(); defaults match lang detection fallback (en) -->
<span class="lang" role="group" aria-label="Language">
<button type="button" data-lang="en" aria-pressed="true">EN</button>
<button type="button" data-lang="zh" aria-pressed="false">中文</button>
</span>
</div>
</div>
<p class="sub" id="sub"></p>
<!-- C-graft: mono inventory strip anchors the hero with factual counts -->
<p class="inventory" id="inventory" aria-live="polite"></p>
<div class="gap"></div>
</header>
<main id="app"></main>
<footer id="footer"></footer>
<script type="module">
import { mount } from './src/index.js';
// Sentinel markup for the 6 DOM effects (they query their own [data-*] hooks inside the mount root).
const DOM_SENTINELS = {
scramble: `<p data-scramble style="font-family:'JetBrains Mono',ui-monospace,monospace;font-size:2rem;letter-spacing:.12em;color:#FF5638;margin:0">DECODE</p>`,
magnetic: `<div data-magnetic style="position:relative;width:100%;height:100%;display:flex;gap:12px;align-items:center;justify-content:center;flex-wrap:wrap"><div data-magcursor style="position:absolute;left:0;top:0;width:16px;height:16px;border-radius:50%;border:1px solid #FF5638;pointer-events:none"></div><span data-magchip style="padding:6px 14px;border:1px solid #2a2320;border-radius:999px;color:#ECE5D8">Home</span><span data-magchip style="padding:6px 14px;border:1px solid #2a2320;border-radius:999px;color:#ECE5D8">Work</span><span data-magchip style="padding:6px 14px;border:1px solid #2a2320;border-radius:999px;color:#ECE5D8">About</span></div>`,
kinetic: `<div data-kinetic style="color:#ECE5D8;font-family:'Bricolage Grotesque',system-ui,sans-serif"></div>`,
marquee: `<div style="overflow:hidden;white-space:nowrap;width:100%;color:#ECE5D8;font-family:'JetBrains Mono',ui-monospace,monospace"><div data-marquee style="display:inline-block">FX LAB · ZERO-DEP WEB EFFECTS · PASTE ANYWHERE · FX LAB · ZERO-DEP WEB EFFECTS · PASTE ANYWHERE · </div></div>`,
tilt: `<div data-tilt style="width:200px;height:140px;perspective:600px"><div data-tiltcard style="width:100%;height:100%;background:linear-gradient(135deg,#FF5638,#1b1614);border-radius:10px;display:flex;align-items:center;justify-content:center;color:#ECE5D8;font-weight:700;font-family:'Bricolage Grotesque',system-ui,sans-serif">Tilt me</div></div>`,
spot: `<div data-spot style="position:relative;width:100%;height:100%;background:#141010;color:#ECE5D8;overflow:hidden;-webkit-mask-image:radial-gradient(140px circle at var(--mx,50%) var(--my,50%),#000 0,transparent 72%);mask-image:radial-gradient(140px circle at var(--mx,50%) var(--my,50%),#000 0,transparent 72%)"><div style="padding:1rem;font-size:.95rem;line-height:1.5">Move the cursor to reveal the spotlight mask.</div></div>`,
};
const esc = (s) => String(s ?? '').replace(/[&<>"]/g, c => ({ '&':'&','<':'<','>':'>','"':'"' }[c]));
// medium label, museum-placard style (replaces the old kind-pill).
const MEDIUM = { shader:'glsl · webgl2', canvas:'canvas · 2d', dom:'dom · css' };
// Per-pixel canvas effects flagged cpu:"high" render at a lower internal resolution and let the
// browser upscale (CSS size is 100%). Costs drop ~scale² with no coordinate-space change — a
// thumbnail is too small to notice the softness. Tune here; 1 disables.
const HEAVY_RES_SCALE = 0.5;
const mountOpts = (el) => el.dataset.perfCpu === 'high' ? { resScale: HEAVY_RES_SCALE } : {};
// --- i18n: standard locale dict + browser-language detection + persisted toggle ---
const STRINGS = {
en: {
sub: "99 zero-dependency web effects — WebGL2 shaders, Canvas-2D, and DOM — hung like artworks. Each is a paste-anywhere snippet. Walk the wall below, or if you're an LLM, start at /llms.txt.",
loading: 'loading 99 effects…', footer: 'fx-lab · MIT · the paste is the install',
snippet: 'read the snippet →', failed: 'Failed to load fx-index.json — run `npm run build`.',
},
zh: {
sub: '99 个零依赖网页特效 —— WebGL2 着色器、Canvas-2D 与 DOM,如同展墙上的作品。每个都是可粘贴即用的片段。向下浏览展墙;若你是 LLM,请从 /llms.txt 开始。',
loading: '正在加载 99 个特效…', footer: 'fx-lab · MIT · 粘贴即安装',
snippet: '查看片段 →', failed: '加载 fx-index.json 失败 —— 请运行 `npm run build`。',
},
};
let lang = (() => {
const saved = localStorage.getItem('fxlab-lang');
if (saved === 'en' || saved === 'zh') return saved;
return (navigator.language || '').toLowerCase().startsWith('zh') ? 'zh' : 'en';
})();
const titleOf = (fx) => lang === 'zh' ? (fx.nameLocal || fx.name) : fx.name;
const subOf = (fx) => lang === 'zh' ? (fx.nameLocal ? fx.name : '') : (fx.nameLocal || '');
const summaryOf = (fx) => lang === 'zh' ? (fx.descriptionZh || fx.summary) : fx.summary;
const sectionOf = (s) => lang === 'zh' ? (s.nameLocal || s.name) : s.name;
const secRefs = [], tileRefs = []; // refs so a language switch re-labels in place — effects keep running
function applyLang() {
const S = STRINGS[lang];
document.documentElement.lang = lang === 'zh' ? 'zh-CN' : 'en';
document.getElementById('sub').textContent = S.sub;
document.getElementById('footer').textContent = S.footer;
const lt = document.getElementById('loader-text'); if (lt) lt.innerHTML = '<b>FX Lab</b> · ' + esc(S.loading);
for (const b of document.querySelectorAll('.lang button')) {
b.classList.toggle('active', b.dataset.lang === lang);
b.setAttribute('aria-pressed', b.dataset.lang === lang ? 'true' : 'false'); // a11y: reflect state
}
for (const r of secRefs) r.el.textContent = sectionOf(r.s);
for (const r of tileRefs) {
r.name.innerHTML = esc(titleOf(r.fx)) + (subOf(r.fx) ? `<small>${esc(subOf(r.fx))}</small>` : '');
r.summary.textContent = summaryOf(r.fx);
r.detail.textContent = S.snippet;
}
}
function setLang(l) { const prev = lang; lang = l; localStorage.setItem('fxlab-lang', l); applyLang(); if (window.mixpanel) mixpanel.track('language_switch', { language: l, from: prev }); }
for (const b of document.querySelectorAll('.lang button')) b.addEventListener('click', () => setLang(b.dataset.lang));
applyLang(); // loader text + toggle state before data arrives
// Mixpanel engagement tracking. Gallery has no auth, so events are anonymous
// (the SDK auto-generates a stable distinct_id). We track explicit actions,
// not autotrack, because each tile is a <canvas>-hosting <div> and autotrack
// would log noise on every scroll-driven mount.
document.addEventListener('click', (e) => {
if (!window.mixpanel) return;
const a = e.target.closest('a');
if (!a) return;
// Catalog / GitHub links in the header (external or non-effect files).
const detail = a.classList.contains('detail') ? null : (a.getAttribute('href') || '');
if (a.classList.contains('detail')) {
// The per-effect "view details" link — the primary engagement signal.
const fx = a.closest('.piece') && a.closest('.piece').querySelector('.fx');
mixpanel.track('effect_view', { effect_id: fx ? fx.dataset.id : null, kind: fx ? fx.dataset.kind : null });
} else if (a.classList.contains('gh')) {
mixpanel.track('github_click');
} else if (detail && /\.txt$/.test(detail)) {
mixpanel.track('catalog_view', { file: detail.split('/').pop() });
} else if (detail && /\.json$/.test(detail)) {
mixpanel.track('catalog_view', { file: detail.split('/').pop() });
}
});
// Lazy mount/unmount: keeps live WebGL2 contexts under the ~8 cap and saves battery.
const io = new IntersectionObserver((entries) => {
for (const e of entries) {
const fx = e.target;
if (e.isIntersecting && !fx._handle) {
const id = fx.dataset.id, kind = fx.dataset.kind;
if (kind === 'dom') fx.innerHTML = DOM_SENTINELS[id] || '';
fx._handle = mount(fx, id, mountOpts(fx));
} else if (!e.isIntersecting && fx._handle) {
fx._handle.stop(); fx._handle = null;
if (fx.dataset.kind === 'dom') fx.innerHTML = '';
}
}
}, { rootMargin: '100px' });
// Loading effect: mount our own 'spinners' (Loaders) effect on the overlay until the grid is ready.
const loaderEl = document.getElementById('loader');
const loaderHandle = mount(loaderEl.querySelector('.loader-fx'), 'spinners');
function dismissLoader(startedAt) {
const wait = Math.max(0, 500 - (performance.now() - startedAt)); // keep it on screen >=0.5s so it doesn't flash
setTimeout(() => {
loaderEl.classList.add('hide');
setTimeout(() => { loaderHandle.stop(); loaderEl.remove(); }, 550);
}, wait);
}
(async () => {
const startedAt = performance.now();
const data = await fetch('./fx-index.json').then(r => r.json()).catch((e) => {
document.getElementById('loader-text').textContent = STRINGS[lang].failed;
throw e;
});
const bySection = new Map(data.sections.map(s => [s.id, []]));
for (const fx of data.effects) (bySection.get(fx.section) || []).push(fx);
// C-graft: populate mono inventory strip with factual counts
const counts = data.effects.reduce((acc, fx) => { acc[fx.kind] = (acc[fx.kind] || 0) + 1; return acc; }, {});
const inv = document.getElementById('inventory');
if (inv) inv.textContent = `${data.effects.length} effects · ${counts.canvas || 0} canvas · ${counts.shader || 0} shader · 0 dependencies`;
const app = document.getElementById('app');
app.innerHTML = '';
for (const s of data.sections) {
const items = bySection.get(s.id) || [];
if (!items.length) continue;
const sec = document.createElement('section');
sec.className = 'room';
const head = document.createElement('div');
head.className = 'room-head';
const h2 = document.createElement('h2'); h2.className = 'room-title';
const tally = document.createElement('span'); tally.className = 'tally';
tally.textContent = String(items.length).padStart(2, '0'); // language-neutral room count
head.append(h2, tally);
secRefs.push({ s, el: h2 });
const wall = document.createElement('div');
wall.className = 'wall';
items.forEach((fx, idx) => {
const piece = document.createElement('figure');
piece.className = 'piece' + (idx === 0 ? ' feature' : ''); // first work of each room hangs large
piece.innerHTML =
// a11y: aria-hidden on decorative canvas mount targets — screen readers skip the canvas noise
// data-perf-cpu drives resScale downscaling for cpu:"high" effects (see mountOpts).
`<div class="fx" aria-hidden="true" data-id="${esc(fx.id)}" data-kind="${esc(fx.kind)}" data-perf-cpu="${esc((fx.perf && fx.perf.cpu) || '')}"></div>` +
`<figcaption class="placard">` +
`<div class="placard-row"><h3 class="name"></h3>` +
`<span class="medium">${esc(MEDIUM[fx.kind] || fx.kind)}</span></div>` +
`<p class="summary"></p>` +
`<a class="detail" href="./effects/${esc(fx.id)}.md"></a>` +
`</figcaption>`;
wall.appendChild(piece);
tileRefs.push({ fx, name: piece.querySelector('.name'), summary: piece.querySelector('.summary'), detail: piece.querySelector('.detail') });
io.observe(piece.querySelector('.fx'));
});
sec.append(head, wall);
app.appendChild(sec);
}
applyLang(); // fill section + tile text in the current language
dismissLoader(startedAt);
})();
</script>
</body>
</html>