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): retain larger footage at its natural ratio

EtienneLescotea6e9402a01c
diff --git a/website/src/components/Recreation/driver.ts b/website/src/components/Recreation/driver.ts
index 6374e3894..6175b7381 100644
--- a/website/src/components/Recreation/driver.ts
+++ b/website/src/components/Recreation/driver.ts
@@ -23,7 +23,7 @@
*/
import { CURSORS } from "./generated";
-import { followHeight } from "./layout";
+import { followHeight, footageSize } from "./layout";
import { createPlayback, DOCK_VIEWPORTS, followDock } from "./playback";
import {
BEATS,
@@ -442,24 +442,25 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
heroWidth =
window.innerWidth * (window.innerWidth > 900 ? 0.91 : 1) -
(window.innerWidth > 900 ? 0 : 36);
- dockWidth = card.offsetWidth;
+ dockWidth = card.getBoundingClientRect().width;
previewScale = heroWidth / dockWidth;
}
if (withTargets) measureVisible(claimed);
}
};
// Measure final panes, never their temporary combined cross-fade height.
- // The largest closing pane sets one bottom inset for the entire tour.
+ // The largest closing group sets one bottom inset for the entire tour.
root.style.setProperty("--timeline-bottom", "0px");
measurePanes(false);
+ timelineHeight = timeline.offsetHeight;
if (window.innerWidth > 900) {
const closingHeight = Math.max(paneHeights.get("timeline")!, paneHeights.get("transcript")!);
- root.style.setProperty("--timeline-content-h", `${closingHeight}px`);
+ const closingPicture = footageSize(dockWidth, closingHeight, fullBoxHeight - timelineHeight);
+ root.style.setProperty("--timeline-content-h", `${closingPicture.height}px`);
} else {
root.style.removeProperty("--timeline-content-h");
}
root.style.removeProperty("--timeline-bottom");
- timelineHeight = timeline.offsetHeight;
timelineInset = Number.parseFloat(getComputedStyle(timeline).bottom);
measurePanes(true);
if (had === undefined) delete root.dataset.beat;
@@ -493,7 +494,10 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
} else {
root.style.removeProperty("--column-h");
}
- fitCard(Number(root.style.getPropertyValue("--dock")));
+ fitCard(
+ Number(root.style.getPropertyValue("--dock")),
+ Number(root.style.getPropertyValue("--tl")),
+ );
};
const at = (name: string, fx = 20, fy = 45): [number, number] => {
@@ -644,13 +648,18 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
const num = (n: string, v: number, dp = 4) => root.style.setProperty(n, v.toFixed(dp));
- const fitCard = (dock: number) => {
+ const fitCard = (dock: number, timelineOn: number) => {
const scale = previewScale + (1 - previewScale) * dock;
num("--card-scale", scale);
if (window.innerWidth > 900) {
- const height = (heroWidth * 0.5625 * (1 - dock) + columnHeight * dock) / scale;
+ const picture = footageSize(
+ dockWidth,
+ columnHeight,
+ fullBoxHeight - timelineOn * (timelineHeight + timelineInset),
+ );
+ const height = (heroWidth * 0.5625 * (1 - dock) + picture.height * dock) / scale;
root.style.setProperty("--card-height", `${height.toFixed(3)}px`);
- num("--footage-fit", Math.min(1, height / (dockWidth * 0.5625)));
+ num("--footage-fit", Math.min(1, height / (picture.width * 0.5625)));
} else {
root.style.removeProperty("--card-height");
num("--footage-fit", 1);
@@ -659,7 +668,7 @@ export function attachDriver(refs: DriverRefs, cls: DriverClasses): () => void {
const apply = (f: Frame, dock: number, phase: string) => {
num("--dock", dock);
- fitCard(dock);
+ fitCard(dock, f.tl);
// 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);
diff --git a/website/src/components/Recreation/layout.test.ts b/website/src/components/Recreation/layout.test.ts
index e62bea831..79d97b57b 100644
--- a/website/src/components/Recreation/layout.test.ts
+++ b/website/src/components/Recreation/layout.test.ts
@@ -1,7 +1,31 @@
import assert from "node:assert/strict";
import { test } from "node:test";
-import { followHeight } from "./layout.ts";
+import { followHeight, footageSize } from "./layout.ts";
+
+test("a picture taller than the inspector keeps its full 16:9 size", () => {
+ const size = footageSize(1238, 497, 964);
+ assert.equal(size.width, 1238);
+ assert.equal(size.height, 696.375);
+});
+
+test("a picture shorter than the inspector extends its height without narrowing it", () => {
+ const size = footageSize(609, 410, 489);
+ assert.equal(size.width, 609);
+ assert.equal(size.height, 410);
+});
+
+test("a short viewport reduces the picture proportionally to leave room for the timeline", () => {
+ const size = footageSize(1238, 316, 374);
+ assert.ok(Math.abs(size.height - 374) < 0.000001);
+ assert.ok(Math.abs(size.width / size.height - 16 / 9) < 0.000001);
+});
+
+test("a viewport-fitted picture still aligns with a taller inspector", () => {
+ const size = footageSize(1238, 298, 279);
+ assert.equal(size.height, 298);
+ assert.ok(Math.abs(size.width - 279 * (16 / 9)) < 0.000001);
+});
test("pane height changes stay between their endpoints and settle without a yoyo", () => {
for (const [from, target] of [
diff --git a/website/src/components/Recreation/layout.ts b/website/src/components/Recreation/layout.ts
index e1a61a5ed..e91b902b2 100644
--- a/website/src/components/Recreation/layout.ts
+++ b/website/src/components/Recreation/layout.ts
@@ -1,3 +1,9 @@
+/** Fit a 16:9 picture in the viewport, then extend it only for a taller inspector. */
+export function footageSize(width: number, columnHeight: number, availableHeight: number) {
+ const fittedWidth = Math.min(width, availableHeight * (16 / 9));
+ return { width: fittedWidth, height: Math.max(fittedWidth * (9 / 16), columnHeight) };
+}
+
/** Follow a settled pane height without ever overshooting it. */
export function followHeight(current: number, target: number, elapsed: number): number {
if (Math.abs(target - current) < 0.25) return target;
diff --git a/website/src/components/Recreation/styles.module.css b/website/src/components/Recreation/styles.module.css
index 9b3c4afe6..8ee8fc9ec 100644
--- a/website/src/components/Recreation/styles.module.css
+++ b/website/src/components/Recreation/styles.module.css
@@ -8,8 +8,8 @@
* 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
* 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.
+ * floor. Its background can be taller than the left column, and extends to
+ * that column's height when needed. The recorded content keeps its proportions.
*
* 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
@@ -256,7 +256,7 @@
/* ── the grid, once ── */
/* Centre the inspector and footage as one bounded group on wide screens. */
- --editor-w: min(91vw, 1280px);
+ --editor-w: min(91vw, 1600px);
--editor-l: calc((100vw - var(--editor-w)) / 2);
--c2x: calc(var(--editor-l) + var(--pnl-w) + 26px);
--c2w: calc(var(--editor-w) - var(--pnl-w) - 26px);
@@ -286,10 +286,11 @@
/* 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 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);
+ /* Keep the largest 16:9 picture that fits, with the left group as its
+ minimum height. Extra height becomes background padding. */
+ --dock-w: min(var(--c2w), calc(var(--box-h) * 1.77777778));
+ --dock-h: max(calc(var(--dock-w) * 0.5625), var(--column-h, var(--box-h)));
+ --dock-l: calc(var(--c2x) + (var(--c2w) - var(--dock-w)) / 2);
--dock-t: calc(var(--box-top) + (var(--box-h) - var(--dock-h)) / 2);
--hero-w: 91vw;
--hero-l: 4.5vw;
@@ -387,8 +388,8 @@
/* ═══ THE CAPTIONS ═════════════════════════════════════════════════════════ */
-/* One controlled height for the caption, its pane and the picture. The panes
- overlap while fading, so their combined transition height never sizes it. */
+/* The left group sets a minimum height for the picture. Overlapping the panes
+ while fading keeps their combined transition height out of that minimum. */
.column {
position: absolute;
left: var(--editor-l);