Skip to content

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

feat(timeline): a navigator that shows what it navigates

EtienneLescot10eff148681a
diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.css
index fcdbadd13..946fcf07a 100644
--- a/src/components/ai-edition/v4/EditorShellV4.module.css
+++ b/src/components/ai-edition/v4/EditorShellV4.module.css
@@ -1307,9 +1307,9 @@
/* The pan/zoom bar's band, kept here (not just on .tlNav) because the playhead
layer stretches by exactly this much to run behind it, down to the panel's
bottom edge. */
- --tl-nav-h: 20px;
- --tl-nav-gap-top: 8px;
- --tl-nav-gap-bottom: 12px;
+ --tl-nav-h: 14px;
+ --tl-nav-gap-top: 6px;
+ --tl-nav-gap-bottom: 8px;
--tl-nav-band: calc(var(--tl-nav-h) + var(--tl-nav-gap-top) + var(--tl-nav-gap-bottom));
}
.tlToolbar {
@@ -1948,44 +1948,60 @@
}
.tlNavTrack {
position: absolute;
- top: 7px;
- left: 0;
- right: 0;
- height: 6px;
- border-radius: 3px;
- background: var(--surface-3);
+ inset: 0;
+ border-radius: 999px;
+ background: color-mix(in oklab, var(--fg) 6%, transparent);
+ overflow: hidden;
+}
+.tlNavClip {
+ position: absolute;
+ top: 4px;
+ bottom: 4px;
+ border-radius: 999px;
+ background: color-mix(in oklab, var(--accent) 40%, transparent);
}
+/* The visible stretch: a lit frame over the miniature. */
.tlNavWindow {
position: absolute;
- top: 5px;
- height: 10px;
- border-radius: 5px;
- background: var(--surface-hi);
- border: 1px solid var(--border-hi);
+ top: 0;
+ bottom: 0;
+ border-radius: 999px;
+ border: 1.5px solid color-mix(in oklab, var(--fg) 38%, transparent);
+ background: color-mix(in oklab, var(--fg) 7%, transparent);
box-sizing: border-box;
cursor: grab;
+ transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
+}
+.tlNavWindow:hover {
+ border-color: var(--accent);
+ background: var(--accent-soft);
}
.tlNavWindow:active {
cursor: grabbing;
}
-.tlNavHandle {
+/* A grip on each edge, the shape of a slider thumb: white, shadowed, a 16px grab area. */
+.tlNavGrip {
position: absolute;
- top: 0;
- bottom: 0;
- width: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
+ top: -4px;
+ bottom: -4px;
+ width: 16px;
+ display: grid;
+ place-items: center;
cursor: ew-resize;
- z-index: 3;
+ z-index: 1;
}
-.tlNavHandle span {
- width: 4px;
- height: 14px;
- border-radius: 2px;
- background: var(--fg-2);
- box-shadow: 0 0 0 2px var(--surface);
+.tlNavGrip[data-edge="start"] { left: -8px; }
+.tlNavGrip[data-edge="end"] { right: -8px; }
+.tlNavGrip::before {
+ content: "";
+ width: 6px;
+ height: 16px;
+ border-radius: 999px;
+ background: #fff;
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18), 0 1px 3px rgb(0 0 0 / 0.3);
+ transition: transform var(--motion-fast) var(--ease);
}
+.tlNavGrip:hover::before { transform: scaleY(1.15); }
/* V4Timeline — region resize handles, toolbar aspect control */
.lanePillHandle {
diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
index 80f0a7de0..4e846aefd 100644
--- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
@@ -529,9 +529,10 @@ describe("V4Timeline clip row", () => {
const { clipEls } = renderTimeline(CLIPS);
const widths = clipEls.map((el) => el.style.width);
// (jsdom re-serialises the percentage to 4 decimals, hence the numeric read)
- expect(widths.map((w) => w.endsWith("- 6px)"))).toEqual([true, true, true]);
+ // The last card has nothing to be separated from, so it reaches the end.
+ expect(widths.map((w) => w.endsWith("- 6px)"))).toEqual([true, true, false]);
for (const [i, durSec] of [600, 300, 900].entries()) {
- expect(Number.parseFloat(widths[i].slice("calc(".length))).toBeCloseTo(
+ expect(Number.parseFloat(widths[i].replace("calc(", ""))).toBeCloseTo(
(durSec / TOTAL_SEC) * 100,
3,
);
diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx
index 1f296abb8..75a014e01 100644
--- a/src/components/ai-edition/v4/V4Timeline.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.tsx
@@ -2239,6 +2239,9 @@ export function V4Timeline({
// The gutter is taken out of the card's own width below, so the
// room the label actually has is that much less than the span.
const durText = formatSec(dur);
+ // The gutter separates two cards; the last one has nothing after it and
+ // reaches the end of the timeline.
+ const gutterPx = i === clips.length - 1 ? 0 : CLIP_GUTTER_PX;
return (
<div
key={c.id}
@@ -2256,7 +2259,9 @@ export function V4Timeline({
// flex row's `gap`). A clip shorter than the gutter lands on
// .tlClip's 1px min-width instead of collapsing — same rule as
// the lane pills above.
- width: `calc(${pctOf(boxLen)}% - ${CLIP_GUTTER_PX}px)`,
+ width: gutterPx
+ ? `calc(${pctOf(boxLen)}% - ${gutterPx}px)`
+ : `${pctOf(boxLen)}%`,
transform: clipTransform,
}}
onPointerDown={(e) => startClipDrag(e, c)}
@@ -2300,7 +2305,7 @@ export function V4Timeline({
>
<Pencil size={15} />
</button>
- {cardFitsDuration(boxLen * pxPerSec - CLIP_GUTTER_PX, durText) ? (
+ {cardFitsDuration(boxLen * pxPerSec - gutterPx, durText) ? (
<span className={styles.tlClipDuration}>{durText}</span>
) : null}
</div>
@@ -2353,28 +2358,43 @@ export function V4Timeline({
on screen at once, and there is nothing to zoom INTO without lanes. */}
{showLanes ? (
<div ref={navRef} className={styles.tlNav}>
- <div className={styles.tlNavTrack} />
+ {/* The whole timeline in miniature: where the footage is, so the window reads as
+ a view onto it rather than as a bare scrollbar. */}
+ <div className={styles.tlNavTrack} aria-hidden>
+ {clips.map((c) => (
+ <span
+ key={c.id}
+ className={styles.tlNavClip}
+ style={{
+ left: `${pctOf(c.timelineStartSec).toFixed(2)}%`,
+ width: `${pctOf(c.timelineEndSec - c.timelineStartSec).toFixed(2)}%`,
+ }}
+ />
+ ))}
+ </div>
<div
className={styles.tlNavWindow}
+ title={t("labels.pan")}
style={{
left: `${(nav.start * 100).toFixed(2)}%`,
width: `${((nav.end - nav.start) * 100).toFixed(2)}%`,
}}
onPointerDown={(e) => startNavDrag("pan", e)}
- />
- <div
- className={styles.tlNavHandle}
- style={{ left: `calc(${(nav.start * 100).toFixed(2)}% - 6px)` }}
- onPointerDown={(e) => startNavDrag("left", e)}
- >
- <span />
- </div>
- <div
- className={styles.tlNavHandle}
- style={{ left: `calc(${(nav.end * 100).toFixed(2)}% - 6px)` }}
- onPointerDown={(e) => startNavDrag("right", e)}
>
- <span />
+ {/* Grips on the window's own edges: pulling one zooms, as a range slider's
+ thumbs would. */}
+ <span
+ className={styles.tlNavGrip}
+ data-edge="start"
+ title={t("labels.zoom")}
+ onPointerDown={(e) => startNavDrag("left", e)}
+ />
+ <span
+ className={styles.tlNavGrip}
+ data-edge="end"
+ title={t("labels.zoom")}
+ onPointerDown={(e) => startNavDrag("right", e)}
+ />
</div>
</div>
) : null}