Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(website): let the timeline arrive, and the inspector fit what is in it

Etienne Lescot85e1d75be3e8
diff --git a/website/src/components/Recreation/driver.ts b/website/src/components/Recreation/driver.ts
index 57da2b4ac..73500a706 100644
--- a/website/src/components/Recreation/driver.ts
+++ b/website/src/components/Recreation/driver.ts
@@ -267,6 +267,12 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
let camReady = false;
let camPending: number | undefined;
const camSrc = "/video/webcam.mp4";
+
+ // Set at attach, not in the markup and not in primeCam: in the markup every
+ // phone fetches it for a bubble it never draws, and in primeCam it would
+ // race the clip it exists to stand in for. Here it has the whole approach to
+ // the band to arrive, and the driver only ever attaches above 901px.
+ cam.poster = "/img/walkthrough/webcam-poster.jpg";
const primeCam = () => {
if (cam.getAttribute("src")) return;
cam.setAttribute("src", camSrc);
@@ -289,6 +295,30 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
};
cam.addEventListener("loadeddata", onCamLoaded);
cam.addEventListener("seeked", onCamSeeked);
+ /* ── the swatch strip ─────────────────────────────────────────────────── */
+
+ /* The twelve wallpapers are `loading="lazy"` inside a pane that is
+ `display: none` until the style beat opens — which means the browser never
+ gets a chance to want them early, and all twelve are requested at the
+ moment they are first needed. Measured on a 1.5 Mbps link: the strip was
+ still blank half a second into the beat it belongs to.
+
+ Warmed here rather than in the markup: this runs on the same in-band gate
+ that primes the clip, so it costs nothing until the reader is actually
+ arriving, and nothing at all below 901px, where the driver never attaches
+ and the strip is never drawn. */
+ let stripPrimed = false;
+ const primeStrip = () => {
+ if (stripPrimed) return;
+ stripPrimed = true;
+ for (const img of Array.from(root.querySelectorAll<HTMLImageElement>("[data-strip] img"))) {
+ img.loading = "eager";
+ img.decode?.().catch(() => {
+ // A decode that loses a race with teardown is not worth reporting.
+ });
+ }
+ };
+
const seekCam = (tf: number) => {
if (!camReady || cam.readyState < 2) return;
const dur = Number.isFinite(cam.duration) && cam.duration > 0 ? cam.duration : 10;
@@ -320,7 +350,11 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
const apply = (f: Frame) => {
num("--t", f.t, 3);
num("--tf", f.tf, 3);
- num("--tl", f.tl, 0);
+ // Three decimals, not zero. This was written at `toFixed(0)` from when --tl
+ // was a switch; the score has eased it into a ramp since, and rounding to
+ // the integer threw the ramp away and snapped the floor, the panel and the
+ // composite from one act to the other in a single frame.
+ num("--tl", f.tl, 3);
if (String(f.bg) !== root.dataset.bg) root.dataset.bg = String(f.bg);
num("--fit", f.fit);
num("--pad-pct", f.paddingPct, 2);
@@ -421,7 +455,10 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
// sitting pinned and finished for a whole viewport.
const span = total + window.innerHeight * 1.04;
const off = Math.min(span, Math.max(0, -rect.top));
- if (off > 0 && off < span) primeCam();
+ if (off > 0 && off < span) {
+ primeCam();
+ primeStrip();
+ }
apply(frameAt(span > 0 ? off / span : 0));
});
};
diff --git a/website/src/components/Recreation/index.tsx b/website/src/components/Recreation/index.tsx
index d68d79408..475915430 100644
--- a/website/src/components/Recreation/index.tsx
+++ b/website/src/components/Recreation/index.tsx
@@ -216,7 +216,7 @@ export default function Recreation() {
))}
</span>
<span className={styles.upload}>{PANELS.background.uploadCustom}</span>
- <span className={styles.swatches}>
+ <span className={styles.swatches} data-strip="">
{WALLPAPERS.slice(0, WALLPAPER_COUNT_SHOWN).map((n, i) => (
<span
key={n}
@@ -224,6 +224,15 @@ export default function Recreation() {
data-t={i < 4 ? `th-${i}` : undefined}
style={{ ["--i" as string]: i }}
>
+ {/* Lazy, and warmed by the driver — see primeStrip(). These
+ twelve sit in a pane held at `display: none` until the
+ style beat opens, and a lazy image inside a display:none
+ box never intersects anything, so all twelve fired at
+ once when the beat arrived and the strip painted blank
+ for the first half second of it. Loading them eagerly
+ fixes that and costs every phone 48 KB for a strip no
+ phone ever sees, because the scene needs 901px. The
+ driver only ever runs above that width. */}
<img
src={`/img/walkthrough/wp-${String(n).padStart(2, "0")}.jpg`}
alt=""
@@ -452,6 +461,12 @@ export default function Recreation() {
{/* 16/10.5, not a circle. */}
<span className={styles.webcam}>
+ {/* No poster attribute: the driver sets one. `preload="none"` and a
+ src withheld until the reader is inside the band mean this
+ bordered, shadowed box paints EMPTY until the clip's first frame
+ decodes — just over a second on a 1.5 Mbps link. A poster in the
+ markup fixes that and bills every phone 6.9 KB for a bubble no
+ phone draws, because the scene needs 901px. */}
<video
ref={cam}
className={styles.webcamVideo}
diff --git a/website/src/components/Recreation/scene.ts b/website/src/components/Recreation/scene.ts
index d3e0fc599..83b4ddce2 100644
--- a/website/src/components/Recreation/scene.ts
+++ b/website/src/components/Recreation/scene.ts
@@ -381,7 +381,14 @@ export function frameAt(p: number): Frame {
// Easing the value here instead means every rule that reads `--tl` — the
// floor, the panel's top and height, the composite's box — moves together and
// lands exactly.
- const tl = ease(clamp01((t - TL_IN) / 0.55));
+ //
+ // 1.5s, not 0.55s. The ramp is what the reader sees as the timeline sliding
+ // up from the bottom, and 0.55s of a 26s scene is 2% of the band — about a
+ // wheel notch, which arrives as a jump rather than as an entrance. At 1.5s
+ // it takes just under 6% of the band, and because every rule that reads
+ // --tl moves on it, the panel and the composite resize over the same
+ // stretch instead of snapping ahead of the floor.
+ const tl = ease(clamp01((t - TL_IN) / 1.5));
const bg = BG_PICKS.reduce((n, at) => (t >= at ? n + 1 : n), 0);
diff --git a/website/src/components/Recreation/styles.module.css b/website/src/components/Recreation/styles.module.css
index 473aeb3f1..9943d6738 100644
--- a/website/src/components/Recreation/styles.module.css
+++ b/website/src/components/Recreation/styles.module.css
@@ -239,9 +239,17 @@
.panel {
position: absolute;
left: 4.5vw;
- top: var(--pnl-top);
+ /* Capped by the footage, centred on it, and free to be shorter. Anchoring
+ `height` to the slot left every pane whose controls stop short sitting in
+ a column of empty surface. Both numbers come off the video's own box and
+ not off --pnl-top/--pnl-h: the slot is taller than the video once the
+ timeline is in, and centring on the slot puts the panel 70px below the
+ picture it belongs beside. The video is --v-w wide at 16/9, so its height
+ is --v-w * 0.5625 and its centre line --v-t + half of that. */
+ top: calc(var(--v-t) + var(--v-w) * 0.28125);
width: var(--pnl-w);
- height: var(--pnl-h);
+ height: auto;
+ max-height: calc(var(--v-w) * 0.5625);
overflow: hidden;
z-index: 12;
border: 1px solid var(--ost-border);
@@ -250,7 +258,10 @@
box-shadow: var(--ost-elev-pop), inset 0 1px 0 rgba(255, 255, 255, 0.06);
pointer-events: none;
opacity: var(--panel);
- transform: translateY(calc((1 - var(--panel)) * 12px));
+ /* Two functions rather than one calc: `calc(-50% + Npx)` mixes a percentage
+ with a length, and postcss-calc drops declarations it cannot fold — which
+ on this page is a production-only failure that has bitten twice. */
+ transform: translateY(-50%) translateY(calc((1 - var(--panel)) * 12px));
transition:
opacity 0.45s var(--ease),
transform 0.45s var(--ease);
@@ -660,7 +671,12 @@
top: var(--v-t);
width: var(--v-w);
aspect-ratio: 16 / 9;
- border-radius: 16px;
+ /* 18px, matching .cardClip, which is inset:0 on this same box — so the
+ 1px ring below and the clipped content follow one arc. The design has
+ 16px here against an 18px clip, and the two arcs part company across the
+ quadrant: a dark crescent opens between the ring and the picture, widest
+ at 45 degrees. Reproduced at 6x before changing it. */
+ border-radius: 18px;
box-shadow:
0 0 0 1px rgba(16, 185, 129, 0.5),
0 0 44px -8px rgba(16, 185, 129, 0.3),
diff --git a/website/static/img/walkthrough/webcam-poster.jpg b/website/static/img/walkthrough/webcam-poster.jpg
new file mode 100644
index 000000000..e6e143f40
Binary files /dev/null and b/website/static/img/walkthrough/webcam-poster.jpg differ