Skip to content

Commit ae2f006

Browse files
committed
fix(catalog): reveal Matrix Decode captions with autoAlpha so the docs preview renders
The demo and snippet flipped word spans with zero-duration display sets, which the seek-driven docs player never applies after its style restore: the composition played 8s of black. autoAlpha reveals with the scrambles as same-length absolute overlays follow the keyframes contract (never tween display) and survive seeks and loop wraps. Scramble text now matches each word's length so it decodes in place instead of jumping.
1 parent 7a8f8a0 commit ae2f006

4 files changed

Lines changed: 55 additions & 43 deletions

File tree

docs/catalog/components/caption-matrix-decode.mdx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ That writes one file: `compositions/components/caption-matrix-decode.html`.
9696
position: relative;
9797
}
9898
.sc-real {
99-
display: none;
100-
}
101-
.sc-scr0 {
102-
display: none;
99+
opacity: 0;
100+
visibility: hidden;
103101
}
102+
.sc-scr0,
104103
.sc-scr1 {
105-
display: none;
104+
position: absolute;
105+
left: 0;
106+
top: 0;
107+
white-space: nowrap;
108+
opacity: 0;
109+
visibility: hidden;
106110
}
107111
</style>
108112
</head>
@@ -150,10 +154,10 @@ That writes one file: `compositions/components/caption-matrix-decode.html`.
150154
151155
var ALPHANUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
152156
153-
function scrambleChars(seed) {
157+
function scrambleChars(seed, length) {
154158
var rng = mulberry32(seed);
155159
var result = "";
156-
for (var i = 0; i < 4; i++) {
160+
for (var i = 0; i < length; i++) {
157161
result += ALPHANUM[Math.floor(rng() * ALPHANUM.length)];
158162
}
159163
return result;
@@ -234,13 +238,13 @@ That writes one file: `compositions/components/caption-matrix-decode.html`.
234238
var scr0 = document.createElement("span");
235239
scr0.className = "sc-scr0";
236240
scr0.id = "sc-scr0-" + wi;
237-
scr0.textContent = scrambleChars(wi * 1000 + 0);
241+
scr0.textContent = scrambleChars(wi * 1000 + 0, w.text.length);
238242
wordWrap.appendChild(scr0);
239243
240244
var scr1 = document.createElement("span");
241245
scr1.className = "sc-scr1";
242246
scr1.id = "sc-scr1-" + wi;
243-
scr1.textContent = scrambleChars(wi * 1000 + 1);
247+
scr1.textContent = scrambleChars(wi * 1000 + 1, w.text.length);
244248
wordWrap.appendChild(scr1);
245249
246250
grp.appendChild(wordWrap);
@@ -257,11 +261,11 @@ That writes one file: `compositions/components/caption-matrix-decode.html`.
257261
var scr0El = document.getElementById("sc-scr0-" + wi);
258262
var scr1El = document.getElementById("sc-scr1-" + wi);
259263
260-
tl.set(scr0El, { display: "inline" }, w.start);
261-
tl.set(scr1El, { display: "inline" }, w.start + 0.1);
262-
tl.set(scr0El, { display: "none" }, w.start + 0.1);
263-
tl.set(realEl, { display: "inline" }, w.start + 0.2);
264-
tl.set(scr1El, { display: "none" }, w.start + 0.2);
264+
tl.set(scr0El, { autoAlpha: 1 }, w.start);
265+
tl.set(scr1El, { autoAlpha: 1 }, w.start + 0.1);
266+
tl.set(scr0El, { autoAlpha: 0 }, w.start + 0.1);
267+
tl.set(realEl, { autoAlpha: 1 }, w.start + 0.2);
268+
tl.set(scr1El, { autoAlpha: 0 }, w.start + 0.2);
265269
});
266270
267271
tl.to(grp, { opacity: 0, duration: 0.12 }, g.end - 0.12);

0 commit comments

Comments
 (0)