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): smooth docking and align the responsive preview

EtienneLescot359171a49d28
diff --git a/website/src/components/Recreation/ART-DIRECTION.md b/website/src/components/Recreation/ART-DIRECTION.md
index 409ed1832..81d200d56 100644
--- a/website/src/components/Recreation/ART-DIRECTION.md
+++ b/website/src/components/Recreation/ART-DIRECTION.md
@@ -10,9 +10,17 @@ the reader scrolls, 0.28 viewport of scroll docks it into the editor and
rewinds the displayed scene time to zero. The five beats then run as before.
Scrolling back reverses the same movement and resumes the loop. The pause
button controls the preview; reduced motion gets a still and stacked captions.
-The initial response eases out, with a short catch-up for wheel increments.
-The picture moves by translation and scale rather than reflowing its DOM at
-every intermediate width.
+One short scroll follower controls its position, scale and rewind, including
+the handoff into the editor. A large wheel increment passes through the dock
+seam instead of skipping it. The stage floats in viewport space until it can
+hand back to sticky at the same origin, so native scrolling cannot move it
+between animation frames.
+
+On desktop, the background frame follows the actual height of the caption and
+inspector on its left, including pane transitions. Its ratio can change with
+the viewport and the current beat. The recorded page keeps a separate 16:9
+canvas, fitted uniformly inside that frame; additional padding belongs to the
+background. ResizeObserver follows the column without per-frame layout reads.
## What the previous cut got wrong
diff --git a/website/src/components/Recreation/driver.ts b/website/src/components/Recreation/driver.ts
index 7e994bba3..6bc49002d 100644
--- a/website/src/components/Recreation/driver.ts
+++ b/website/src/components/Recreation/driver.ts
@@ -102,8 +102,11 @@ const WRITTEN = [
"--comment",
"--k",
"--dock",
- "--approach",
+ "--stage-y",
"--card-scale",
+ "--card-height",
+ "--footage-fit",
+ "--column-h",
];
/** Piecewise-linear read of `[[t, ...values]]`, clamped at both ends. */
@@ -160,6 +163,7 @@ function release(refs: DriverRefs, cls: DriverClasses): void {
delete root.dataset.beat;
delete root.dataset.cur;
delete root.dataset.phase;
+ delete root.dataset.floating;
delete refs.band.dataset.driven;
refs.band.style.removeProperty("--hero-offset");
root.dataset.bg = String(frameAt(1).bg);
@@ -182,6 +186,7 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
const { band, root, cam, padValue, flow, pause } = refs;
const hero = document.querySelector<HTMLElement>("[data-home-hero]");
const card = root.querySelector<HTMLElement>("[data-composite]")!;
+ const column = root.querySelector<HTMLElement>("[data-editor-column]")!;
let raf = 0;
const sample = createPlayback(T_TOTAL);
let paused = false;
@@ -191,6 +196,9 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
let dockDistance = window.innerHeight * DOCK_VIEWPORTS;
let heroTop = 0;
let previewScale = 1;
+ let heroWidth = 1;
+ let dockWidth = 1;
+ let columnHeight = 1;
let smoothOffset = 0;
let lastTick: number | undefined;
@@ -384,6 +392,11 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
// Transitions off for the pass: see .stage[data-measuring].
root.dataset.measuring = "";
const kept = GEOMETRY.map((g) => [g.css, root.style.getPropertyValue(g.css)] as const);
+ const layoutKept = ["--column-h", "--card-height", "--footage-fit"].map(
+ (css) => [css, root.style.getPropertyValue(css)] as const,
+ );
+ root.style.removeProperty("--card-height");
+ root.style.setProperty("--footage-fit", "1");
for (const b of BEATS) {
root.dataset.beat = b.id;
// Opening the pane is not enough. Three of the frame's numbers place
@@ -399,17 +412,19 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
// for every beat, including the three that play in the opening one.
const f = frameAt((b.from + b.to) / 2 / T_TOTAL);
for (const g of GEOMETRY) root.style.setProperty(g.css, g.of(f).toFixed(3));
+ root.style.setProperty("--column-h", `${column.offsetHeight}px`);
if (b.id === "style") {
- const heroWidth =
+ heroWidth =
window.innerWidth * (window.innerWidth > 900 ? 0.91 : 1) -
(window.innerWidth > 900 ? 0 : 36);
- previewScale = heroWidth / card.getBoundingClientRect().width;
+ dockWidth = card.offsetWidth;
+ previewScale = heroWidth / dockWidth;
}
measureVisible(claimed);
}
if (had === undefined) delete root.dataset.beat;
else root.dataset.beat = had;
- for (const [css, was] of kept) {
+ for (const [css, was] of [...kept, ...layoutKept]) {
if (was) root.style.setProperty(css, was);
else root.style.removeProperty(css);
}
@@ -428,6 +443,10 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
// After the restore, so the boxes are the ones the reader is looking at.
measureShots();
delete root.dataset.measuring;
+ if (window.innerWidth > 900) {
+ columnHeight = column.getBoundingClientRect().height;
+ root.style.setProperty("--column-h", `${columnHeight}px`);
+ }
};
const at = (name: string, fx = 20, fy = 45): [number, number] => {
@@ -580,7 +599,20 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
const apply = (f: Frame, dock: number, phase: string) => {
num("--dock", dock);
- num("--card-scale", previewScale + (1 - previewScale) * dock);
+ const scale = previewScale + (1 - previewScale) * dock;
+ num("--card-scale", scale);
+ // Keep the first-screen picture in viewport space while it docks. The
+ // browser's unsmoothed document scroll cannot shift it between our frames.
+ root.dataset.floating = String(offset < heroTop || dock < 1);
+ num("--stage-y", heroTop * (1 - dock));
+ if (window.innerWidth > 900) {
+ const height = (heroWidth * 0.5625 * (1 - dock) + columnHeight * dock) / scale;
+ root.style.setProperty("--card-height", `${height.toFixed(3)}px`);
+ num("--footage-fit", Math.min(1, height / (dockWidth * 0.5625)));
+ } else {
+ root.style.removeProperty("--card-height");
+ num("--footage-fit", 1);
+ }
if (hero) {
hero.style.opacity = String((1 - dock) ** 2);
hero.inert = dock === 1;
@@ -683,18 +715,17 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
span = heroTop + rect.height + window.innerHeight * 0.04;
dockDistance = window.innerHeight * DOCK_VIEWPORTS;
offset = Math.min(span, Math.max(0, window.scrollY));
- root.style.setProperty("--approach", `${Math.max(0, rect.top)}px`);
};
const tick = (now: number) => {
raf = 0;
- const target = Math.min(offset, dockDistance);
smoothOffset =
- lastTick === undefined ? target : followDock(smoothOffset, target, now - lastTick);
+ lastTick === undefined
+ ? offset
+ : followDock(smoothOffset, offset, now - lastTick, dockDistance);
lastTick = now;
- const following = smoothOffset !== target;
- const sceneOffset = smoothOffset === dockDistance ? offset : smoothOffset;
+ const following = smoothOffset !== offset;
const playing = visible && !paused && !document.hidden;
- const { time, dock, phase } = sample(now, sceneOffset, span, dockDistance, playing);
+ const { time, dock, phase } = sample(now, smoothOffset, span, dockDistance, playing);
const scored = frameAt(time / T_TOTAL);
// The opening loop shows the picture alone. The first inspector is
// revealed while the picture rewinds, before the scroll score begins.
@@ -743,6 +774,15 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
{ threshold: 0 },
);
observer.observe(root);
+ // ResizeObserver reports the actual flow height, including pane transitions
+ // and translated captions, without forcing a layout read in the animation loop.
+ const columnObserver = new ResizeObserver(([entry]) => {
+ if (window.innerWidth <= 900) return;
+ columnHeight = entry.borderBoxSize[0]?.blockSize ?? entry.contentRect.height;
+ root.style.setProperty("--column-h", `${columnHeight}px`);
+ schedule();
+ });
+ columnObserver.observe(column);
// Coalesced into a frame, like the scroll. `measure()` opens all five beats,
// reads a rect for every `data-t` node and forces layout to do it; a window
@@ -794,6 +834,7 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
document.removeEventListener("visibilitychange", onVisibility);
pause.removeEventListener("click", onPause);
observer.disconnect();
+ columnObserver.disconnect();
// The video outlives the driver — it is the same element on re-attach —
// so listeners left on it accumulate one pair per breakpoint crossing,
// each holding a dead driver's closure alive.
diff --git a/website/src/components/Recreation/index.tsx b/website/src/components/Recreation/index.tsx
index 961fb9e81..168c83ee2 100644
--- a/website/src/components/Recreation/index.tsx
+++ b/website/src/components/Recreation/index.tsx
@@ -319,7 +319,7 @@ export default function Recreation() {
alone, and carries its own aria-hidden: it is a drawing, while the
caption above it is the section's real copy and has to stay in the
accessibility tree. */}
- <div className={styles.column}>
+ <div className={styles.column} data-editor-column="">
{/* ═══ THE CAPTIONS ═══ Above the gate they share one box and take
turns; below it they stack. */}
<div className={styles.captions}>
@@ -534,192 +534,193 @@ export default function Recreation() {
{/* ═══ THE COMPOSITE ═══ */}
<div className={styles.card} data-composite="">
<div className={styles.cardClip}>
- <div className={styles.zoomer} data-shot-box>
- {CANVAS_BG.map((n) => (
- <img
- key={n}
- className={styles.bg}
- data-i={n - 1}
- src={`/img/walkthrough/canvas-bg-${n}.jpg`}
- alt=""
- loading={n === 1 ? undefined : "lazy"}
- decoding="async"
- />
- ))}
-
- {/* The recorded window. `--frame-scale` is a uniform scale, not an
+ {CANVAS_BG.map((n) => (
+ <img
+ key={n}
+ className={styles.bg}
+ data-i={n - 1}
+ src={`/img/walkthrough/canvas-bg-${n}.jpg`}
+ alt=""
+ loading={n === 1 ? undefined : "lazy"}
+ decoding="async"
+ />
+ ))}
+ <div className={styles.footage}>
+ <div className={styles.zoomer} data-shot-box>
+ {/* The recorded window. `--frame-scale` is a uniform scale, not an
inset: the page inside must not reflow while the padding moves. */}
- <div className={styles.frame}>
- <div className={styles.chrome}>
- <span className={styles.lights}>
- <span />
- <span />
- <span />
- </span>
- <span className={styles.omnibox}>fern.garden</span>
- </div>
- <div className={styles.viewport}>
- <div className={styles.page} data-shot-scroll>
- <div className={styles.pageNav}>
- <span className={styles.pageMark} />
- <span className={styles.pageBrand}>Fern</span>
- <span className={styles.pageLinks}>
- <span>Product</span>
- <span>Pricing</span>
- <span>Journal</span>
- </span>
- <span className={styles.pageSignIn}>Sign in</span>
- </div>
- <div className={styles.pageHero}>
- <p className={styles.pageHeadline}>Grow smarter, water less.</p>
- <p>
- Fern watches your plants&apos; soil, light and weather — and waters only
- when they ask for it.
- </p>
- <div className={styles.pageBtns}>
- <span className={styles.pageCta} data-shot="cta">
- Download the app
+ <div className={styles.frame}>
+ <div className={styles.chrome}>
+ <span className={styles.lights}>
+ <span />
+ <span />
+ <span />
+ </span>
+ <span className={styles.omnibox}>fern.garden</span>
+ </div>
+ <div className={styles.viewport}>
+ <div className={styles.page} data-shot-scroll>
+ <div className={styles.pageNav}>
+ <span className={styles.pageMark} />
+ <span className={styles.pageBrand}>Fern</span>
+ <span className={styles.pageLinks}>
+ <span>Product</span>
+ <span>Pricing</span>
+ <span>Journal</span>
</span>
- <span className={styles.pageGhost}>See how it works</span>
+ <span className={styles.pageSignIn}>Sign in</span>
</div>
- </div>
- <div className={styles.pageShot}>
- <img
- src="/img/walkthrough/canvas-poster.jpg"
- alt=""
- loading="lazy"
- decoding="async"
- />
- <span className={styles.pageChip}>Live soil data</span>
- </div>
- {/* The social proof strip and the three feature cards, as the
+ <div className={styles.pageHero}>
+ <p className={styles.pageHeadline}>Grow smarter, water less.</p>
+ <p>
+ Fern watches your plants&apos; soil, light and weather — and waters only
+ when they ask for it.
+ </p>
+ <div className={styles.pageBtns}>
+ <span className={styles.pageCta} data-shot="cta">
+ Download the app
+ </span>
+ <span className={styles.pageGhost}>See how it works</span>
+ </div>
+ </div>
+ <div className={styles.pageShot}>
+ <img
+ src="/img/walkthrough/canvas-poster.jpg"
+ alt=""
+ loading="lazy"
+ decoding="async"
+ />
+ <span className={styles.pageChip}>Live soil data</span>
+ </div>
+ {/* The social proof strip and the three feature cards, as the
design draws them. They were three empty boxes until now; the
take scrolls the page far enough to show them, so they were
the one part of the recorded window that read as unfinished. */}
- <div className={styles.pageProof}>
- <span className={styles.pageFaces}>
- <span data-face="a">LB</span>
- <span data-face="b">AK</span>
- <span data-face="c">JM</span>
- </span>
- <span>
- Loved by <strong>12,400</strong> gardeners
- </span>
- <span>
- <strong>38</strong> countries
- </span>
- <span>
- <strong>4.9</strong> avg rating
- </span>
- </div>
+ <div className={styles.pageProof}>
+ <span className={styles.pageFaces}>
+ <span data-face="a">LB</span>
+ <span data-face="b">AK</span>
+ <span data-face="c">JM</span>
+ </span>
+ <span>
+ Loved by <strong>12,400</strong> gardeners
+ </span>
+ <span>
+ <strong>38</strong> countries
+ </span>
+ <span>
+ <strong>4.9</strong> avg rating
+ </span>
+ </div>
- <div className={styles.pageCards}>
- <article className={styles.pageCard}>
- <div className={`${styles.pageCardArt} ${styles.artDots}`}>
- {[
- [1, 1, 0, 1, 0, 0, 1],
- [0, 1, 0, 0, 1, 0, 0],
- ].map((row, r) => (
- <span key={r}>
- {row.map((on, i) => (
- <span key={i} data-on={on ? "" : undefined} />
- ))}
- </span>
- ))}
- </div>
- <div className={styles.pageCardBody}>
- <div>Auto schedules</div>
- <div>Every pot on its own rhythm.</div>
- </div>
- </article>
-
- <article className={styles.pageCard}>
- <div className={`${styles.pageCardArt} ${styles.artBars}`}>
- {[
- [34, 0.55],
- [58, 0.7],
- [44, 0.6],
- [62, 0.75],
- ].map(([h, o]) => (
- <span key={h} style={{ height: `${h}%`, opacity: o }} />
- ))}
- </div>
- <div className={styles.pageCardBody}>
- <div>Soil signals</div>
- <div>Moisture, light and heat, live.</div>
- </div>
- </article>
-
- <article className={styles.pageCard}>
- <div className={`${styles.pageCardArt} ${styles.artLines}`}>
- {[
- [82, 0.5],
- [64, 0.35],
- [74, 0.45],
- ].map(([w, o]) => (
- <span key={w} style={{ width: `${w}%`, opacity: o }} />
- ))}
- </div>
- <div className={styles.pageCardBody}>
- <div>Harvest notes</div>
- <div>A journal that writes itself.</div>
- </div>
- </article>
+ <div className={styles.pageCards}>
+ <article className={styles.pageCard}>
+ <div className={`${styles.pageCardArt} ${styles.artDots}`}>
+ {[
+ [1, 1, 0, 1, 0, 0, 1],
+ [0, 1, 0, 0, 1, 0, 0],
+ ].map((row, r) => (
+ <span key={r}>
+ {row.map((on, i) => (
+ <span key={i} data-on={on ? "" : undefined} />
+ ))}
+ </span>
+ ))}
+ </div>
+ <div className={styles.pageCardBody}>
+ <div>Auto schedules</div>
+ <div>Every pot on its own rhythm.</div>
+ </div>
+ </article>
+
+ <article className={styles.pageCard}>
+ <div className={`${styles.pageCardArt} ${styles.artBars}`}>
+ {[
+ [34, 0.55],
+ [58, 0.7],
+ [44, 0.6],
+ [62, 0.75],
+ ].map(([h, o]) => (
+ <span key={h} style={{ height: `${h}%`, opacity: o }} />
+ ))}
+ </div>
+ <div className={styles.pageCardBody}>
+ <div>Soil signals</div>
+ <div>Moisture, light and heat, live.</div>
+ </div>
+ </article>
+
+ <article className={styles.pageCard}>
+ <div className={`${styles.pageCardArt} ${styles.artLines}`}>
+ {[
+ [82, 0.5],
+ [64, 0.35],
+ [74, 0.45],
+ ].map(([w, o]) => (
+ <span key={w} style={{ width: `${w}%`, opacity: o }} />
+ ))}
+ </div>
+ <div className={styles.pageCardBody}>
+ <div>Harvest notes</div>
+ <div>A journal that writes itself.</div>
+ </div>
+ </article>
+ </div>
</div>
- </div>
- {/* The app the recording opens, half-way through the take. Two
+ {/* The app the recording opens, half-way through the take. Two
states crossfaded on the footage clock, under one title bar. */}
- <div className={styles.appWin} data-shot-win>
- <div className={styles.appBar} data-shot="app-bar">
- <span className={styles.appLights}>
- <span data-l="r" />
- <span data-l="y" />
- <span data-l="g" />
- </span>
- <span className={styles.appTitle}>Fern — Add a sensor</span>
- <span className={styles.appPad} />
- </div>
-
- <div className={styles.appSetup}>
- <div className={styles.appHead}>Pair a soil sensor</div>
- <div className={styles.appRow}>
- <span className={styles.appDot} />
- Fern Probe · FP-204
- <span className={styles.appMeta}>-42 dBm</span>
+ <div className={styles.appWin} data-shot-win>
+ <div className={styles.appBar} data-shot="app-bar">
+ <span className={styles.appLights}>
+ <span data-l="r" />
+ <span data-l="y" />
+ <span data-l="g" />
+ </span>
+ <span className={styles.appTitle}>Fern — Add a sensor</span>
+ <span className={styles.appPad} />
</div>
- <div className={`${styles.appRow} ${styles.appRowIdle}`}>
- <span className={styles.appDot} />
- Searching nearby…
+
+ <div className={styles.appSetup}>
+ <div className={styles.appHead}>Pair a soil sensor</div>
+ <div className={styles.appRow}>
+ <span className={styles.appDot} />
+ Fern Probe · FP-204
+ <span className={styles.appMeta}>-42 dBm</span>
+ </div>
+ <div className={`${styles.appRow} ${styles.appRowIdle}`}>
+ <span className={styles.appDot} />
+ Searching nearby…
+ </div>
+ <span className={styles.appBtn} data-shot="app-go">
+ Pair sensor
+ </span>
</div>
- <span className={styles.appBtn} data-shot="app-go">
- Pair sensor
- </span>
- </div>
- <div className={styles.appDone}>
- <span className={styles.appTick}>
- <svg viewBox="0 0 24 24" aria-hidden="true">
- <path
- d="M20 6 9 17l-5-5"
- fill="none"
- stroke="#059669"
- strokeWidth="2.6"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- </span>
- <div className={styles.appOk}>Sensor paired</div>
- <div className={styles.appSub}>Bed 3 — South garden is now live.</div>
+ <div className={styles.appDone}>
+ <span className={styles.appTick}>
+ <svg viewBox="0 0 24 24" aria-hidden="true">
+ <path
+ d="M20 6 9 17l-5-5"
+ fill="none"
+ stroke="#059669"
+ strokeWidth="2.6"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ </span>
+ <div className={styles.appOk}>Sensor paired</div>
+ <div className={styles.appSub}>Bed 3 — South garden is now live.</div>
+ </div>
</div>
</div>
</div>
- </div>
- {/* The pointer inside the recording, from the captured telemetry —
+ {/* The pointer inside the recording, from the captured telemetry —
which is what the Cursor panel restyles. */}
- <span className={styles.shotCursor} />
+ <span className={styles.shotCursor} />
+ </div>
</div>
</div>
diff --git a/website/src/components/Recreation/playback.test.ts b/website/src/components/Recreation/playback.test.ts
index 15fce39c6..3b22f83aa 100644
--- a/website/src/components/Recreation/playback.test.ts
+++ b/website/src/components/Recreation/playback.test.ts
@@ -18,7 +18,7 @@ test("docking rewinds from the displayed frame and stays still when scrolling st
sample(0, 0, 8000, 600, true);
sample(10000, 0, 8000, 600, true);
const middle = sample(10000, 300, 8000, 600, true);
- assert.deepEqual(middle, { time: 1.25, dock: 0.875, phase: "docking" });
+ assert.deepEqual(middle, { time: 5, dock: 0.5, phase: "docking" });
assert.deepEqual(sample(20000, 300, 8000, 600, true), middle);
assert.deepEqual(sample(21000, 600, 8000, 600, true), {
time: 0,
@@ -34,7 +34,7 @@ test("scrolling back undoes docking continuously and resumes the loop", () => {
sample(0, 0, 8000, 600, true);
sample(12000, 0, 8000, 600, true);
sample(12000, 4300, 8000, 600, true);
- assert.equal(sample(18000, 300, 8000, 600, true).time, 1.5);
+ assert.equal(sample(18000, 300, 8000, 600, true).time, 6);
assert.equal(sample(19000, 0, 8000, 600, true).time, 12);
assert.equal(sample(20000, 0, 8000, 600, true).time, 13);
});
@@ -45,7 +45,7 @@ test("the first scroll pixel already docks and rewinds the preview", () => {
sample(10000, 0, 8000, 240, true);
const first = sample(10000, 1, 8000, 240, true);
assert.equal(first.phase, "docking");
- assert.ok(first.dock > 0.01);
+ assert.ok(first.dock > 0);
assert.ok(first.time < 10);
assert.equal(sample(10000, 240, 8000, 240, true).phase, "editor");
});
@@ -67,6 +67,25 @@ test("the smoothing has the same pace on 60 Hz and 120 Hz displays", () => {
assert.ok(Math.abs(at(16) - at(8)) < 0.001);
});
+test("a large wheel step travels through the dock seam before advancing the editor", () => {
+ const sample = createPlayback(26);
+ sample(0, 0, 8000, 240, true);
+ sample(10000, 0, 8000, 240, true);
+ let offset = 0;
+ let editor = false;
+ for (let elapsed = 16; elapsed <= 800; elapsed += 16) {
+ offset = followDock(offset, 1000, 16, 240);
+ const frame = sample(10000 + elapsed, offset, 8000, 240, true);
+ if (elapsed === 16) assert.equal(frame.phase, "docking");
+ if (frame.phase === "editor" && !editor) {
+ assert.equal(frame.time, 0, "the editor starts at its first frame");
+ editor = true;
+ }
+ }
+ assert.ok(editor);
+ assert.equal(offset, 1000, "the remaining scroll also settles without a snap");
+});
+
test("landing directly in the editor does not play a preview first", () => {
const sample = createPlayback(26);
assert.deepEqual(sample(1000, 600, 8000, 600, true), {
diff --git a/website/src/components/Recreation/playback.ts b/website/src/components/Recreation/playback.ts
index 8125bb9f2..202e7368a 100644
--- a/website/src/components/Recreation/playback.ts
+++ b/website/src/components/Recreation/playback.ts
@@ -5,7 +5,15 @@ export const DOCK_VIEWPORTS = 0.28;
const clamp = (value: number) => Math.max(0, Math.min(1, value));
/** A short, refresh-rate-independent catch-up for wheel/trackpad increments. */
-export function followDock(current: number, target: number, elapsed: number): number {
+export function followDock(
+ current: number,
+ target: number,
+ elapsed: number,
+ dockDistance = Number.POSITIVE_INFINITY,
+): number {
+ // A large wheel step must still travel through docking. Stop at its seam,
+ // then follow the remaining editor scroll on the next frame instead of snapping.
+ if (current < dockDistance && target >= dockDistance) target = dockDistance;
if (Math.abs(target - current) < 0.5) return target;
return current + (target - current) * (1 - Math.exp(-Math.min(elapsed, 64) / 36));
}
@@ -24,8 +32,9 @@ export function createPlayback(duration: number) {
if (offset <= 0 && lastOffset > 0) previewTime = rewindFrom;
const position = clamp(offset / dockDistance);
- // Respond immediately, then settle gently into the editor.
- const dock = 1 - (1 - position) ** 3;
+ // The scroll follower already eases the motion. A second ease here made
+ // most of the move happen in the first frame of a wheel increment.
+ const dock = position;
const progress = clamp((offset - dockDistance) / Math.max(1, span - dockDistance));
const phase = offset <= 0 ? "preview" : position < 1 ? "docking" : "editor";
const time =
diff --git a/website/src/components/Recreation/styles.module.css b/website/src/components/Recreation/styles.module.css
index 3e854796d..1ca1e0cd9 100644
--- a/website/src/components/Recreation/styles.module.css
+++ b/website/src/components/Recreation/styles.module.css
@@ -7,9 +7,9 @@
* v4 computes its layout in JavaScript from a measured stage. The same
* arithmetic is done here in `calc`, which removes the measurement, the resize
* handler and the re-render that came with it: a nav band, a 336px inspector, a
- * 116px caption block, and the composite contained in what is left, centred in
- * the space between the nav and the floor. The panel's height is locked to the
- * composite's, which is the alignment the design is built on.
+ * caption block, and the composite in what is left between the nav and the
+ * floor. Its background follows the left column's measured height; the
+ * recorded content keeps its proportions inside that adaptable frame.
*
* Lengths here are `vw`/`vh`/px and never `%`. That is not style: a custom
* property is substituted as text, so a `%` inside `--video-w` would resolve
@@ -274,14 +274,15 @@
/* What the column has left for a pane once the caption has taken its share. */
--pane-h: calc(var(--box-h) - var(--cap-h));
- /* The picture is 16:9, as wide as the box allows, and centred in it. */
- --dock-w: min(var(--c2w), var(--box-h) * 1.77778);
- --dock-l: calc(var(--c2x) + (var(--c2w) - var(--dock-w)) / 2);
- --dock-t: calc(var(--box-top) + (var(--box-h) - var(--dock-w) * 0.5625) / 2);
+ /* The background spans the right column and aligns with the left group. */
+ --dock-w: var(--c2w);
+ --dock-h: var(--column-h, var(--box-h));
+ --dock-l: var(--c2x);
+ --dock-t: calc(var(--box-top) + (var(--box-h) - var(--dock-h)) / 2);
--hero-w: 91vw;
--hero-l: 4.5vw;
--v-w: calc(var(--hero-w) * (1 - var(--dock)) + var(--dock-w) * var(--dock));
- --v-h: calc(var(--v-w) * 0.5625);
+ --v-h: calc(var(--hero-w) * 0.5625 * (1 - var(--dock)) + var(--dock-h) * var(--dock));
--v-l: calc(var(--hero-l) * (1 - var(--dock)) + var(--dock-l) * var(--dock));
--v-t: calc(var(--dock-t) * var(--dock));
@@ -291,7 +292,16 @@
overflow: hidden;
font-family: var(--ifm-font-family-base);
isolation: isolate;
- transform: translateY(calc(-1 * var(--approach, 0px) * var(--dock)));
+}
+
+/* The first scroll pixels move the picture on one smoothed clock. A fixed
+ stage avoids compositor scroll moving it before the next animation frame.
+ It hands back to sticky only when both origins are exactly at the top. */
+.band[data-driven] .stage[data-floating="true"] {
+ position: fixed;
+ left: 0;
+ width: 100%;
+ transform: translateY(calc(var(--stage-y, 0) * 1px));
}
.scene {
@@ -970,10 +980,10 @@
left: 0;
top: 0;
width: var(--dock-w);
+ height: var(--card-height, var(--dock-h));
transform: translate(var(--v-l), var(--v-t)) scale(var(--card-scale));
transform-origin: top left;
will-change: transform;
- aspect-ratio: 16 / 9;
/* 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
@@ -995,6 +1005,17 @@
background: #0d1014;
}
+/* Extra room belongs to the background. The recorded page and its pointer
+ share one unchanged 16:9 canvas, uniformly fitted rather than stretched. */
+.footage {
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ width: 100%;
+ aspect-ratio: 16 / 9;
+ transform: translate(-50%, -50%) scale(var(--footage-fit, 1));
+}
+
.zoomer {
position: absolute;
inset: 0;
@@ -1895,6 +1916,7 @@
calc((var(--box-h) - var(--cap-h) - var(--pane-min)) * 1.77778)
);
--dock-l: calc((100vw - var(--dock-w)) / 2);
+ --dock-h: calc(var(--dock-w) * 0.5625);
--dock-t: calc(var(--box-top) + var(--cap-h));
--hero-w: calc(100vw - 2 * var(--gut-h));
--hero-l: var(--gut-h);
@@ -2118,6 +2140,8 @@
left: var(--hero-l);
top: 0;
width: var(--hero-w);
+ height: auto;
+ aspect-ratio: 16 / 9;
transform: none;
will-change: auto;
}