@hyperframes/studio 0.8.111 → 0.8.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{hyperframes-player-DvJeHBHi.js → hyperframes-player-DzJbtQVO.js} +1 -1
- package/dist/assets/{index-SFktf7O1.js → index-DRhF3v4Z.js} +194 -194
- package/dist/assets/{index-C7apTvpr.css → index-DbfKVTId.css} +1 -1
- package/dist/assets/{index--G6c4Q_x.js → index-DgwDQK5G.js} +1 -1
- package/dist/assets/{index-Bt4vDkfw.js → index-n5FUn1xv.js} +1 -1
- package/dist/{chunk-PQFEBX32.js → chunk-BIUXP3PG.js} +2 -2
- package/dist/{chunk-6LUNLTHR.js → chunk-K47E2ZJA.js} +13 -8
- package/dist/chunk-K47E2ZJA.js.map +1 -0
- package/dist/{chunk-QUXZVHOJ.js → chunk-VWT7STY3.js} +2 -2
- package/dist/{domEditingLayers-JQPQGGT7.js → domEditingLayers-V67MS4WP.js} +3 -3
- package/dist/index.d.ts +80 -46
- package/dist/index.html +2 -2
- package/dist/index.js +7294 -6844
- package/dist/index.js.map +1 -1
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +10 -8
- package/src/components/nle/useCanvasZOrderTimelineMirror.ts +2 -2
- package/src/hooks/timelineEditingHelpers.ts +7 -0
- package/src/hooks/timelineMoveAdapter.test.ts +12 -0
- package/src/hooks/timelineMoveAdapter.ts +9 -4
- package/src/hooks/useTimelineGroupEditing.test.tsx +77 -0
- package/src/hooks/useTimelineGroupEditing.ts +5 -1
- package/src/index.ts +7 -0
- package/src/main.tsx +4 -0
- package/src/player/components/ClipBadges.tsx +5 -5
- package/src/player/components/Timeline.ghostLane.test.tsx +8 -61
- package/src/player/components/Timeline.trackPadding.test.tsx +11 -56
- package/src/player/components/TimelineCanvas.tsx +6 -2
- package/src/player/components/TimelineClip.filmstrip.test.tsx +156 -0
- package/src/player/components/TimelineClip.test.tsx +7 -7
- package/src/player/components/TimelineClip.tsx +23 -7
- package/src/player/components/TimelineClipFades.tsx +41 -43
- package/src/player/components/TimelineGestureOverlay.test.tsx +41 -0
- package/src/player/components/TimelineGestureOverlay.tsx +59 -21
- package/src/player/components/TimelineLanes.tsx +18 -16
- package/src/player/components/timelineCallbacks.ts +6 -4
- package/src/player/components/timelineClipChildren.tsx +7 -13
- package/src/player/components/timelineClipDragCommit.test.ts +51 -0
- package/src/player/components/timelineClipDragCommit.ts +63 -21
- package/src/player/components/timelineClipDragGestureLifecycle.ts +18 -2
- package/src/player/components/timelineClipDragPreview.test.ts +47 -31
- package/src/player/components/timelineClipDragPreview.ts +81 -17
- package/src/player/components/timelineClipDragTypes.ts +3 -3
- package/src/player/components/timelineClipFadeGeometry.test.ts +29 -0
- package/src/player/components/timelineClipFadeGeometry.ts +74 -0
- package/src/player/components/timelineCollision.ts +51 -11
- package/src/player/components/timelineDragLanding.ts +20 -6
- package/src/player/components/timelineLaneProps.ts +3 -8
- package/src/player/components/timelineMotionStyles.test.ts +6 -13
- package/src/player/components/timelineMountFixtures.tsx +65 -0
- package/src/player/components/timelineOptimisticRevision.ts +15 -4
- package/src/player/components/timelineTheme.ts +2 -0
- package/src/player/components/timelineTrackDisplay.ts +1 -1
- package/src/player/components/timelineTrackInsertLayout.test.ts +249 -0
- package/src/player/components/timelineTrackInsertLayout.ts +71 -0
- package/src/player/components/timelineZMirror.ts +5 -11
- package/src/player/components/useTimelineClipDrag.keyboard.test.tsx +163 -0
- package/src/player/components/useTimelineClipDrag.ts +116 -12
- package/src/player/components/useTimelineDisplayLayout.test.tsx +59 -0
- package/src/player/components/useTimelineKeyboardActor.ts +86 -7
- package/src/player/components/useTimelineProviderState.tsx +3 -1
- package/src/player/components/useTimelineRowVirtualization.test.tsx +56 -0
- package/src/player/components/useTimelineRowVirtualization.ts +3 -1
- package/src/player/components/useTimelineTrackDerivations.test.ts +14 -1
- package/src/player/components/useTimelineTrackDerivations.ts +32 -18
- package/src/player/components/useTimelineTrackLayout.ts +43 -14
- package/src/player/hooks/timelinePlayerSync.test.ts +7 -0
- package/src/player/hooks/timelinePlayerSync.ts +1 -0
- package/src/player/lib/automationStoreSync.test.ts +15 -0
- package/src/player/lib/automationStoreSync.ts +13 -5
- package/src/player/lib/storedVolume.ts +7 -0
- package/src/player/lib/thumbnailPageLifecycle.test.ts +123 -0
- package/src/player/lib/thumbnailPageLifecycle.ts +27 -0
- package/src/player/lib/thumbnailScheduler.ts +20 -2
- package/src/player/lib/timelineElementHelpers.ts +2 -8
- package/src/styles/components.css +71 -19
- package/src/styles/theme.css +4 -1
- package/dist/chunk-6LUNLTHR.js.map +0 -1
- /package/dist/{chunk-PQFEBX32.js.map → chunk-BIUXP3PG.js.map} +0 -0
- /package/dist/{chunk-QUXZVHOJ.js.map → chunk-VWT7STY3.js.map} +0 -0
- /package/dist/{domEditingLayers-JQPQGGT7.js.map → domEditingLayers-V67MS4WP.js.map} +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import React, { act } from "react";
|
|
4
|
+
import { compile } from "tailwindcss";
|
|
5
|
+
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { loadStylesheet, STYLES_DIR } from "../../styles/styleSources";
|
|
7
|
+
import { cleanupMounted, trackedRoot } from "../../components/ui/mountHost.testHelpers";
|
|
8
|
+
import { TimelineClip } from "./TimelineClip";
|
|
9
|
+
import { renderClipChildren } from "./timelineClipChildren";
|
|
10
|
+
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
11
|
+
|
|
12
|
+
let css: string;
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
css = (
|
|
16
|
+
await compile('@import "tailwindcss";\n@import "./theme.css";\n@import "./components.css";', {
|
|
17
|
+
base: STYLES_DIR,
|
|
18
|
+
loadStylesheet: async (id, base) => loadStylesheet(id, base),
|
|
19
|
+
})
|
|
20
|
+
).build(["absolute", "inset-0", "overflow-hidden"]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
cleanupMounted();
|
|
25
|
+
usePlayerStore.getState().setLintFindingsByElement(new Map());
|
|
26
|
+
document.body.innerHTML = "";
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function render(tag: string, overrides: Partial<TimelineElement> = {}, picture = true) {
|
|
30
|
+
const host = document.createElement("div");
|
|
31
|
+
document.body.append(host);
|
|
32
|
+
const root = trackedRoot(host);
|
|
33
|
+
const element: TimelineElement = {
|
|
34
|
+
id: "clip",
|
|
35
|
+
label: "City",
|
|
36
|
+
tag,
|
|
37
|
+
start: 0,
|
|
38
|
+
duration: 1,
|
|
39
|
+
track: 0,
|
|
40
|
+
...overrides,
|
|
41
|
+
};
|
|
42
|
+
const renderContent = picture ? () => <img alt="" /> : undefined;
|
|
43
|
+
act(() => {
|
|
44
|
+
root.render(
|
|
45
|
+
<TimelineClip
|
|
46
|
+
el={element}
|
|
47
|
+
pps={200}
|
|
48
|
+
clipY={0}
|
|
49
|
+
clipHeight={42}
|
|
50
|
+
isSelected
|
|
51
|
+
isHovered={false}
|
|
52
|
+
hasCustomContent={picture}
|
|
53
|
+
capabilities={{ canMove: true, canTrimStart: true, canTrimEnd: true }}
|
|
54
|
+
isComposition={false}
|
|
55
|
+
onHoverStart={vi.fn()}
|
|
56
|
+
onHoverEnd={vi.fn()}
|
|
57
|
+
onClick={vi.fn()}
|
|
58
|
+
onDoubleClick={vi.fn()}
|
|
59
|
+
>
|
|
60
|
+
{renderClipChildren(
|
|
61
|
+
element,
|
|
62
|
+
{ clip: "#222", label: "#fff", accent: "#fff" },
|
|
63
|
+
renderContent,
|
|
64
|
+
undefined,
|
|
65
|
+
)}
|
|
66
|
+
</TimelineClip>,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
return host;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
describe("Filmstrip clips", () => {
|
|
73
|
+
it.each(["video", "img"])("reserves a 15px name band above %s pictures", (tag) => {
|
|
74
|
+
const host = render(tag);
|
|
75
|
+
const name = host.querySelector(".timeline-clip__name");
|
|
76
|
+
const picture = host.querySelector(".timeline-clip__content");
|
|
77
|
+
expect(name?.textContent).toBe("City");
|
|
78
|
+
expect(picture).not.toBeNull();
|
|
79
|
+
expect(picture?.querySelector("img")).not.toBeNull();
|
|
80
|
+
expect(css).toMatch(/--timeline-clip-band-height:\s*15px;/);
|
|
81
|
+
expect(css).toMatch(
|
|
82
|
+
/\.timeline-clip:not\(\.is-audio\) \.timeline-clip__label\s*\{[^}]*height:\s*var\(--timeline-clip-band-height\)/,
|
|
83
|
+
);
|
|
84
|
+
expect(css).toMatch(
|
|
85
|
+
/\.timeline-clip:not\(\.is-audio\) \.timeline-clip__content\s*\{[^}]*top:\s*var\(--timeline-clip-band-height\);[^}]*border-top-left-radius:\s*0;/,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("keeps applied-state badges above the opaque name band", () => {
|
|
90
|
+
const host = render("video", { hasAudio: true, volume: 1.8 });
|
|
91
|
+
expect(host.querySelector('[data-badge="volume"]')?.textContent).toBe("180%");
|
|
92
|
+
const badges = host.querySelector('[data-testid="clip-badges"]');
|
|
93
|
+
expect(badges?.classList.contains("z-[31]")).toBe(true);
|
|
94
|
+
expect(badges?.classList.contains("max-w-[calc(100%-12px)]")).toBe(true);
|
|
95
|
+
expect(badges?.classList.contains("overflow-hidden")).toBe(true);
|
|
96
|
+
expect(badges?.parentElement?.classList.contains("timeline-clip__label")).toBe(true);
|
|
97
|
+
expect(css).toMatch(
|
|
98
|
+
/\.timeline-clip:not\(\.is-audio\) \.timeline-clip__name\s*\{[^}]*flex:\s*1;[^}]*min-width:\s*0;[^}]*overflow:\s*hidden;/,
|
|
99
|
+
);
|
|
100
|
+
expect(css).toMatch(
|
|
101
|
+
/\.timeline-clip:not\(\.is-audio\) \.timeline-clip__label\s*\{[^}]*z-index:\s*auto;/,
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("keeps fallback lint warnings clear of the name band and menu badge", () => {
|
|
106
|
+
usePlayerStore
|
|
107
|
+
.getState()
|
|
108
|
+
.setLintFindingsByElement(new Map([["clip", { count: 1, messages: ["Lint warning"] }]]));
|
|
109
|
+
const host = render("div", { duration: 0.3 }, false);
|
|
110
|
+
const name = host.querySelector(".timeline-clip__name");
|
|
111
|
+
const warning = host.querySelector<HTMLElement>('[title="Lint warning"]');
|
|
112
|
+
expect(warning).not.toBeNull();
|
|
113
|
+
expect(warning?.style.bottom).toBe("7px");
|
|
114
|
+
expect(warning?.style.top).toBe("");
|
|
115
|
+
expect(css).toMatch(/\.timeline-clip__timecode\s*\{[^}]*right:\s*16px;/);
|
|
116
|
+
expect(
|
|
117
|
+
(name?.compareDocumentPosition(warning!) ?? 0) & Node.DOCUMENT_POSITION_FOLLOWING,
|
|
118
|
+
).toBeTruthy();
|
|
119
|
+
expect(css).toMatch(
|
|
120
|
+
/\.timeline-clip:not\(\.is-audio\) \.timeline-clip__label\s*\{[^}]*z-index:\s*auto;/,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it.each([0.02, 0.295])(
|
|
125
|
+
"keeps the name band without badge targets on a narrow visual clip (%ss)",
|
|
126
|
+
(duration) => {
|
|
127
|
+
const host = render("video", { duration, hasAudio: true, volume: 1.8 });
|
|
128
|
+
expect(host.querySelector(".timeline-clip__name")?.textContent).toBe("City");
|
|
129
|
+
expect(host.querySelector('[data-testid="clip-badges"]')).toBeNull();
|
|
130
|
+
expect(css).toMatch(/padding:\s*0 min\(6px,\s*25%\);/);
|
|
131
|
+
expect(css).toMatch(/padding-left:\s*min\(8px,\s*25%\);/);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
it("lets audio keep its full-height content and pill radius", () => {
|
|
136
|
+
const host = render("audio");
|
|
137
|
+
const clip = host.querySelector(".timeline-clip");
|
|
138
|
+
const picture = host.querySelector(".timeline-clip__content");
|
|
139
|
+
expect(clip?.classList.contains("is-audio")).toBe(true);
|
|
140
|
+
expect(picture?.classList.contains("inset-0")).toBe(true);
|
|
141
|
+
expect(css).toMatch(/--timeline-clip-audio-radius:\s*21px;/);
|
|
142
|
+
expect(clip instanceof HTMLElement && clip.style.borderRadius).toBe(
|
|
143
|
+
"var(--timeline-clip-audio-radius)",
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("exports a single 1px selection ring around a 12px visual clip", () => {
|
|
148
|
+
const clip = render("video").querySelector(".timeline-clip");
|
|
149
|
+
expect(clip?.classList.contains("is-selected")).toBe(true);
|
|
150
|
+
expect(css).toMatch(/--timeline-clip-radius:\s*12px;/);
|
|
151
|
+
expect(css).toMatch(
|
|
152
|
+
/\.timeline-clip\.is-selected,\s*\.timeline-clip\[data-active\]\.is-selected\s*\{[^}]*outline:\s*1px solid var\(--timeline-clip-selection\);[^}]*outline-offset:\s*0;/,
|
|
153
|
+
);
|
|
154
|
+
expect(css).toMatch(/\.timeline-clip:not\(\.is-audio\)\s*\{\s*border-width:\s*0;/);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -127,7 +127,7 @@ describe("TimelineClip", () => {
|
|
|
127
127
|
element: { id: "hero", label: "Hero", tag: "div", start: 1, duration: 1, track: 0 },
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
expect(host.querySelector(".timeline-
|
|
130
|
+
expect(host.querySelector(".timeline-clip__name")?.textContent).toBe("Hero");
|
|
131
131
|
expect(host.querySelector(".timeline-clip__timecode")).toBeNull();
|
|
132
132
|
|
|
133
133
|
act(() => root.unmount());
|
|
@@ -145,7 +145,7 @@ describe("TimelineClip", () => {
|
|
|
145
145
|
playbackRate: 1.5,
|
|
146
146
|
},
|
|
147
147
|
});
|
|
148
|
-
expect(fast.host.querySelector(".timeline-
|
|
148
|
+
expect(fast.host.querySelector(".timeline-clip__name")?.textContent).toBe("Hero [150%]");
|
|
149
149
|
act(() => fast.root.unmount());
|
|
150
150
|
const automation = JSON.stringify({
|
|
151
151
|
version: 1,
|
|
@@ -170,18 +170,18 @@ describe("TimelineClip", () => {
|
|
|
170
170
|
automation,
|
|
171
171
|
},
|
|
172
172
|
});
|
|
173
|
-
expect(ramp.host.querySelector(".timeline-
|
|
173
|
+
expect(ramp.host.querySelector(".timeline-clip__name")?.textContent).toBe("Hero [ramp]");
|
|
174
174
|
act(() => ramp.root.unmount());
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
it("
|
|
177
|
+
it("keeps the name band under 60px even when the clip is selected", () => {
|
|
178
178
|
const { host, root } = renderClip({
|
|
179
179
|
element: { id: "fx", label: "FX", tag: "div", start: 0, duration: 1, track: 0 },
|
|
180
180
|
pps: 59,
|
|
181
181
|
isSelected: true,
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
expect(host.querySelector(".timeline-
|
|
184
|
+
expect(host.querySelector(".timeline-clip__name")?.textContent).toBe("FX");
|
|
185
185
|
expect(host.querySelector(".timeline-clip__timecode")).toBeNull();
|
|
186
186
|
expect(host.querySelector(".timeline-clip")?.getAttribute("data-ladder")).toBe("picture");
|
|
187
187
|
|
|
@@ -193,7 +193,7 @@ describe("TimelineClip", () => {
|
|
|
193
193
|
element: { id: "wide", label: "City", tag: "video", start: 0, duration: 1, track: 0 },
|
|
194
194
|
pps: 200,
|
|
195
195
|
});
|
|
196
|
-
expect(labeled.host.querySelector(".timeline-
|
|
196
|
+
expect(labeled.host.querySelector(".timeline-clip__name")?.textContent).toBe("City");
|
|
197
197
|
expect(labeled.host.querySelector(".timeline-clip")?.getAttribute("data-ladder")).toBe(
|
|
198
198
|
"labeled",
|
|
199
199
|
);
|
|
@@ -207,7 +207,7 @@ describe("TimelineClip", () => {
|
|
|
207
207
|
pps: 23,
|
|
208
208
|
isSelected: true,
|
|
209
209
|
});
|
|
210
|
-
expect(frame.host.querySelector(".timeline-
|
|
210
|
+
expect(frame.host.querySelector(".timeline-clip__name")?.textContent).toBe("City");
|
|
211
211
|
expect(frame.host.querySelector(".timeline-clip")?.getAttribute("data-ladder")).toBe("frame");
|
|
212
212
|
act(() => frame.root.unmount());
|
|
213
213
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memo, type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import type { TimelineElement } from "../store/playerStore";
|
|
3
3
|
import {
|
|
4
|
+
CLIP_TRIM_HIT_PX,
|
|
4
5
|
clipWidthLadder,
|
|
5
6
|
defaultTimelineTheme,
|
|
6
7
|
getClipHandleOpacity,
|
|
@@ -70,9 +71,10 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
70
71
|
const widthPx = Math.max(el.duration * pps, 4);
|
|
71
72
|
const handleOpacity = getClipHandleOpacity({ isHovered, isSelected, isDragging });
|
|
72
73
|
const displayLabel = `${el.label || el.id || el.tag}${clipSpeedSuffix(el.playbackRate, el.automation)}`;
|
|
74
|
+
const isAudioClip = isAudioTimelineElement(el);
|
|
73
75
|
const ladder = clipWidthLadder(widthPx);
|
|
74
76
|
const showHandles = handleOpacity > 0.01 && (widthPx >= 32 || isSelected);
|
|
75
|
-
const showLabel = ladder === "labeled";
|
|
77
|
+
const showLabel = !isAudioClip || ladder === "labeled";
|
|
76
78
|
const showDefaultText = !hasCustomContent && ladder === "labeled";
|
|
77
79
|
const startLabel = el.start.toFixed(1);
|
|
78
80
|
const endLabel = (el.start + el.duration).toFixed(1);
|
|
@@ -88,9 +90,12 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
88
90
|
} as CSSProperties;
|
|
89
91
|
const linkColor = linkLabelColor(el.link);
|
|
90
92
|
if (linkColor) Object.assign(themeVariables, { "--clip-link-color": linkColor });
|
|
91
|
-
const isAudioClip = isAudioTimelineElement(el);
|
|
92
93
|
const hasFades = (isAudioClip || Boolean(el.hasAudio)) && !isGestureActor;
|
|
93
94
|
const fade = useClipFadeDraft(el);
|
|
95
|
+
const badges =
|
|
96
|
+
ladder === "labeled" && !isGestureActor ? (
|
|
97
|
+
<ClipBadges el={el} onOpenMenu={onContextMenu} />
|
|
98
|
+
) : null;
|
|
94
99
|
const clipClassName = [
|
|
95
100
|
"timeline-clip",
|
|
96
101
|
"absolute",
|
|
@@ -136,12 +141,18 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
136
141
|
tabIndex={isGestureActor ? undefined : tabIndex}
|
|
137
142
|
aria-label={`${displayLabel}, ${startLabel} to ${endLabel} seconds`}
|
|
138
143
|
aria-pressed={isGestureActor ? undefined : isSelected}
|
|
144
|
+
aria-keyshortcuts={isGestureActor || !capabilities.canMove ? undefined : "Space"}
|
|
145
|
+
aria-description={
|
|
146
|
+
isGestureActor || !capabilities.canMove
|
|
147
|
+
? undefined
|
|
148
|
+
: "Space picks up. Up and Down choose a new track. Enter drops. Escape cancels."
|
|
149
|
+
}
|
|
139
150
|
className={clipClassName}
|
|
140
151
|
style={style}
|
|
141
152
|
title={
|
|
142
153
|
isComposition
|
|
143
154
|
? `${el.compositionSrc} • Double-click to open`
|
|
144
|
-
: `${displayLabel} • ${
|
|
155
|
+
: `${displayLabel} • ${startLabel}s – ${endLabel}s`
|
|
145
156
|
}
|
|
146
157
|
onPointerEnter={onHoverStart}
|
|
147
158
|
onPointerLeave={onHoverEnd}
|
|
@@ -160,7 +171,7 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
160
171
|
left: 0,
|
|
161
172
|
top: 0,
|
|
162
173
|
bottom: 0,
|
|
163
|
-
width:
|
|
174
|
+
width: CLIP_TRIM_HIT_PX,
|
|
164
175
|
cursor: "col-resize",
|
|
165
176
|
zIndex: 4,
|
|
166
177
|
}}
|
|
@@ -190,7 +201,7 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
190
201
|
right: 0,
|
|
191
202
|
top: 0,
|
|
192
203
|
bottom: 0,
|
|
193
|
-
width:
|
|
204
|
+
width: CLIP_TRIM_HIT_PX,
|
|
194
205
|
cursor: "col-resize",
|
|
195
206
|
zIndex: 4,
|
|
196
207
|
}}
|
|
@@ -210,8 +221,13 @@ export const TimelineClip = memo(function TimelineClip({
|
|
|
210
221
|
/>
|
|
211
222
|
</div>
|
|
212
223
|
)}
|
|
213
|
-
{showLabel &&
|
|
214
|
-
|
|
224
|
+
{showLabel && (
|
|
225
|
+
<span className="timeline-clip__label">
|
|
226
|
+
<span className="timeline-clip__name">{displayLabel}</span>
|
|
227
|
+
{!isAudioClip && badges}
|
|
228
|
+
</span>
|
|
229
|
+
)}
|
|
230
|
+
{isAudioClip && badges}
|
|
215
231
|
{!isGestureActor && el.syncOrigin && <OutOfSyncBadge el={el} />}
|
|
216
232
|
{showDefaultText && (
|
|
217
233
|
<span className="timeline-clip__timecode">
|
|
@@ -20,6 +20,14 @@ import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
|
20
20
|
import { Tooltip } from "../../components/ui";
|
|
21
21
|
import { useTimelineEditContextOptional } from "../../contexts/TimelineEditContext";
|
|
22
22
|
import { releasedOutsideWindow } from "./timelinePointerRelease";
|
|
23
|
+
import {
|
|
24
|
+
FADE_TAB_CENTER_IN_HIT,
|
|
25
|
+
FADE_TAB_WIDTH,
|
|
26
|
+
fadeHandleBoxes,
|
|
27
|
+
type FadeEdge,
|
|
28
|
+
type FadeHandleBox,
|
|
29
|
+
type FadeHandleClipBox,
|
|
30
|
+
} from "./timelineClipFadeGeometry";
|
|
23
31
|
import {
|
|
24
32
|
collectTimelineSnapTargets,
|
|
25
33
|
snapTimelineTime,
|
|
@@ -28,14 +36,9 @@ import {
|
|
|
28
36
|
type TimelineSnapType,
|
|
29
37
|
} from "./timelineSnapping";
|
|
30
38
|
|
|
31
|
-
type FadeEdge = "in" | "out";
|
|
32
39
|
type FadeDraft = { edge: FadeEdge; seconds: number } | null;
|
|
33
40
|
|
|
34
|
-
const TAB_WIDTH = 4;
|
|
35
41
|
const TAB_HEIGHT = 15;
|
|
36
|
-
const HANDLE_HIT = 24;
|
|
37
|
-
const TAB_INSET = 7;
|
|
38
|
-
const TAB_CENTER_IN_HIT = 8;
|
|
39
42
|
const HANDLE_Z_ABOVE_CLIP_CONTENT = 30;
|
|
40
43
|
const SUPPRESS_CLIP_NATIVE_TITLE = "";
|
|
41
44
|
/** Pixels of pointer travel before a press on the handle counts as a drag. */
|
|
@@ -102,12 +105,6 @@ function keyedFadeSeconds(key: string, shift: boolean, current: number, limit: n
|
|
|
102
105
|
return FADE_KEYS[key]?.(current, shift ? 1 : 0.1, limit) ?? null;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
function topEdgeY(x: number, widthPx: number, heightPx: number, radiusPx: number): number {
|
|
106
|
-
const r = Math.min(radiusPx, widthPx / 2, heightPx / 2);
|
|
107
|
-
const d = x < r ? r - x : x > widthPx - r ? x - (widthPx - r) : 0;
|
|
108
|
-
return d > 0 ? r - Math.sqrt(Math.max(0, r * r - d * d)) : 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
108
|
/** Slim tabs at each fade's end that drag `data-fade-in` / `data-fade-out`. */
|
|
112
109
|
// fallow-ignore-next-line complexity
|
|
113
110
|
export function TimelineClipFades({
|
|
@@ -135,14 +132,29 @@ export function TimelineClipFades({
|
|
|
135
132
|
const visible =
|
|
136
133
|
fades.fadeIn > 0 || fades.fadeOut > 0 || showHandles || dragging !== null || focused !== null;
|
|
137
134
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
138
|
-
const [clipBox, setClipBox] = useState({
|
|
135
|
+
const [clipBox, setClipBox] = useState<FadeHandleClipBox>({
|
|
136
|
+
height: 0,
|
|
137
|
+
width: 0,
|
|
138
|
+
radius: 0,
|
|
139
|
+
toolsLeft: null,
|
|
140
|
+
});
|
|
139
141
|
useLayoutEffect(() => {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
+
const root = rootRef.current;
|
|
143
|
+
const clip = root?.parentElement;
|
|
144
|
+
if (!root || !clip) return;
|
|
142
145
|
const radius = parseFloat(getComputedStyle(clip).borderTopLeftRadius) || 0;
|
|
143
|
-
const height =
|
|
146
|
+
const { clientHeight: height, clientWidth: width } = root;
|
|
147
|
+
const fx = clip.querySelector('[data-badge="fx"]');
|
|
148
|
+
const toolsLeft = fx
|
|
149
|
+
? fx.getBoundingClientRect().left - root.getBoundingClientRect().left
|
|
150
|
+
: null;
|
|
144
151
|
setClipBox((box) =>
|
|
145
|
-
box.height === height &&
|
|
152
|
+
box.height === height &&
|
|
153
|
+
box.width === width &&
|
|
154
|
+
box.radius === radius &&
|
|
155
|
+
box.toolsLeft === toolsLeft
|
|
156
|
+
? box
|
|
157
|
+
: { height, width, radius, toolsLeft },
|
|
146
158
|
);
|
|
147
159
|
}, [widthPx, visible]);
|
|
148
160
|
|
|
@@ -332,39 +344,25 @@ export function TimelineClipFades({
|
|
|
332
344
|
const handlesVisible = showHandles || dragging !== null || focused !== null;
|
|
333
345
|
if (!visible) return null;
|
|
334
346
|
|
|
335
|
-
const hitWidth = Math.min(HANDLE_HIT, widthPx / 2);
|
|
336
|
-
const tabX = (edge: FadeEdge) => {
|
|
337
|
-
const knee = edge === "in" ? inPx : widthPx - outPx;
|
|
338
|
-
const inset = Math.min(TAB_INSET, widthPx / 2);
|
|
339
|
-
return Math.min(widthPx - inset, Math.max(inset, knee));
|
|
340
|
-
};
|
|
341
|
-
const boxLeft = (x: number) => Math.min(widthPx - hitWidth, Math.max(0, x - hitWidth / 2));
|
|
342
|
-
const [inX, outX] = [tabX("in"), tabX("out")];
|
|
343
|
-
const mid = (inX + outX) / 2;
|
|
344
347
|
// A handle with no 0.01 s step to move is not drawn, unless in use: its twin owns the spot.
|
|
345
348
|
const drawn = (edge: FadeEdge) =>
|
|
346
349
|
currentSeconds(edge) > 0 ||
|
|
347
350
|
Math.round(limitFor(edge) * 100) >= 1 ||
|
|
348
351
|
dragging === edge ||
|
|
349
352
|
focused === edge;
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
: [mid, Math.min(widthPx, mid + hitWidth)];
|
|
359
|
-
const edgeY = topEdgeY(x, widthPx, clipBox.height, clipBox.radius);
|
|
360
|
-
return { left, width: right - left, tabLeft: x - left, top: edgeY + 1 - TAB_CENTER_IN_HIT };
|
|
361
|
-
};
|
|
362
|
-
const handleStyle = (geometry: { left: number; top: number; width: number }): CSSProperties => ({
|
|
353
|
+
const handleBoxes = fadeHandleBoxes({
|
|
354
|
+
widthPx,
|
|
355
|
+
inPx,
|
|
356
|
+
outPx,
|
|
357
|
+
clipBox,
|
|
358
|
+
drawn: { in: drawn("in"), out: drawn("out") },
|
|
359
|
+
});
|
|
360
|
+
const handleStyle = (geometry: FadeHandleBox): CSSProperties => ({
|
|
363
361
|
position: "absolute",
|
|
364
362
|
top: geometry.top,
|
|
365
363
|
left: geometry.left,
|
|
366
364
|
width: geometry.width,
|
|
367
|
-
height:
|
|
365
|
+
height: geometry.height,
|
|
368
366
|
cursor: "ew-resize",
|
|
369
367
|
opacity: handlesVisible ? 1 : 0,
|
|
370
368
|
pointerEvents: handlesVisible && canEdit ? "auto" : "none",
|
|
@@ -417,7 +415,7 @@ export function TimelineClipFades({
|
|
|
417
415
|
)}
|
|
418
416
|
{canEdit &&
|
|
419
417
|
(["in", "out"] as const).filter(drawn).map((edge) => {
|
|
420
|
-
const geometry =
|
|
418
|
+
const geometry = handleBoxes[edge];
|
|
421
419
|
return (
|
|
422
420
|
<FadeHandle
|
|
423
421
|
key={edge}
|
|
@@ -428,7 +426,7 @@ export function TimelineClipFades({
|
|
|
428
426
|
snapLabel={dragging === edge && snapType ? SNAP_LABEL[snapType] : null}
|
|
429
427
|
style={handleStyle(geometry)}
|
|
430
428
|
tabLeft={geometry.tabLeft}
|
|
431
|
-
tabTop={
|
|
429
|
+
tabTop={FADE_TAB_CENTER_IN_HIT - TAB_HEIGHT / 2}
|
|
432
430
|
focusable={focusable}
|
|
433
431
|
dragging={dragging === edge}
|
|
434
432
|
onPointerDown={onHandlePointerDown(edge)}
|
|
@@ -560,9 +558,9 @@ function FadeHandle({
|
|
|
560
558
|
aria-hidden="true"
|
|
561
559
|
className="timeline-fade-tab"
|
|
562
560
|
style={{
|
|
563
|
-
left: tabLeft -
|
|
561
|
+
left: tabLeft - FADE_TAB_WIDTH / 2,
|
|
564
562
|
top: tabTop,
|
|
565
|
-
width:
|
|
563
|
+
width: FADE_TAB_WIDTH,
|
|
566
564
|
height: TAB_HEIGHT,
|
|
567
565
|
pointerEvents: "none",
|
|
568
566
|
}}
|
|
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
6
6
|
import { defaultTimelineTheme } from "./timelineTheme";
|
|
7
7
|
import { TimelineGestureOverlay } from "./TimelineGestureOverlay";
|
|
8
8
|
import type { DraggedClipState } from "./timelineClipDragTypes";
|
|
9
|
+
import { createTimelineRowGeometry } from "./timelineLayout";
|
|
9
10
|
import { getTrackStyle } from "./useTimelineTrackLayout";
|
|
10
11
|
|
|
11
12
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
@@ -32,6 +33,40 @@ const drag: DraggedClipState = {
|
|
|
32
33
|
afterEach(() => document.body.replaceChildren());
|
|
33
34
|
|
|
34
35
|
describe("TimelineGestureOverlay", () => {
|
|
36
|
+
it("anchors an insert actor inside the opened seam at its drop time", () => {
|
|
37
|
+
const host = document.createElement("div");
|
|
38
|
+
document.body.append(host);
|
|
39
|
+
const root = createRoot(host);
|
|
40
|
+
act(() =>
|
|
41
|
+
root.render(
|
|
42
|
+
<TimelineGestureOverlay
|
|
43
|
+
drag={{ ...drag, insertRow: 1 }}
|
|
44
|
+
scrollRef={{
|
|
45
|
+
current: {
|
|
46
|
+
scrollLeft: 0,
|
|
47
|
+
scrollTop: 0,
|
|
48
|
+
getBoundingClientRect: () => ({ left: 0, top: 0 }),
|
|
49
|
+
} as HTMLDivElement,
|
|
50
|
+
}}
|
|
51
|
+
pixelsPerSecond={100}
|
|
52
|
+
contentOrigin={232}
|
|
53
|
+
rowGeometry={createTimelineRowGeometry([0, -1, 1], [48, 48, 48], { top: 0 })}
|
|
54
|
+
rowHeight={42}
|
|
55
|
+
selectedElementId="hero"
|
|
56
|
+
currentTime={4}
|
|
57
|
+
theme={defaultTimelineTheme}
|
|
58
|
+
getTrackStyle={getTrackStyle}
|
|
59
|
+
/>,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
const actor = host.querySelector<HTMLElement>("[data-timeline-gesture-actor]");
|
|
63
|
+
expect(actor?.style.left).toBe("632px");
|
|
64
|
+
expect(actor?.style.top).toBe("75px");
|
|
65
|
+
expect(host.querySelector("[data-timeline-new-track-label]")?.textContent).toContain(
|
|
66
|
+
"+ New track",
|
|
67
|
+
);
|
|
68
|
+
act(() => root.unmount());
|
|
69
|
+
});
|
|
35
70
|
it("keeps the drag actor mounted without a source-row node", () => {
|
|
36
71
|
const host = document.createElement("div");
|
|
37
72
|
document.body.append(host);
|
|
@@ -47,6 +82,8 @@ describe("TimelineGestureOverlay", () => {
|
|
|
47
82
|
drag={drag}
|
|
48
83
|
scrollRef={{ current: scroll }}
|
|
49
84
|
pixelsPerSecond={100}
|
|
85
|
+
contentOrigin={232}
|
|
86
|
+
rowGeometry={createTimelineRowGeometry([0, 1, 2], [48, 48, 48])}
|
|
50
87
|
rowHeight={42}
|
|
51
88
|
selectedElementId="hero"
|
|
52
89
|
currentTime={4}
|
|
@@ -82,6 +119,8 @@ describe("TimelineGestureOverlay", () => {
|
|
|
82
119
|
} as HTMLDivElement,
|
|
83
120
|
}}
|
|
84
121
|
pixelsPerSecond={100}
|
|
122
|
+
contentOrigin={232}
|
|
123
|
+
rowGeometry={createTimelineRowGeometry([0, 1, 2], [48, 48, 48])}
|
|
85
124
|
rowHeight={42}
|
|
86
125
|
selectedElementId="hero"
|
|
87
126
|
currentTime={4}
|
|
@@ -109,6 +148,8 @@ describe("TimelineGestureOverlay", () => {
|
|
|
109
148
|
drag={null}
|
|
110
149
|
scrollRef={{ current: null }}
|
|
111
150
|
pixelsPerSecond={100}
|
|
151
|
+
contentOrigin={232}
|
|
152
|
+
rowGeometry={createTimelineRowGeometry([0, 1, 2], [48, 48, 48])}
|
|
112
153
|
rowHeight={42}
|
|
113
154
|
selectedElementId={null}
|
|
114
155
|
currentTime={0}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { memo
|
|
2
|
-
import type { TimelineElement } from "../store/playerStore";
|
|
1
|
+
import { memo } from "react";
|
|
3
2
|
import type { TimelineTheme } from "./timelineTheme";
|
|
4
3
|
import { getRenderedTimelineElement } from "./timelineTheme";
|
|
4
|
+
import { CLIP_Y, type TimelineRowGeometry } from "./timelineLayout";
|
|
5
5
|
import { TimelineClip } from "./TimelineClip";
|
|
6
6
|
import { getTimelineEditCapabilities } from "./timelineEditing";
|
|
7
7
|
import { renderClipChildren } from "./timelineClipChildren";
|
|
@@ -9,23 +9,21 @@ import { getTimelineDragOverlayPosition } from "./timelineClipDragPreview";
|
|
|
9
9
|
import type { DraggedClipState } from "./timelineClipDragTypes";
|
|
10
10
|
import type { TrackVisualStyle } from "./timelineIcons";
|
|
11
11
|
import { isTimelineClipActive } from "./useTimelineActiveClips";
|
|
12
|
-
import type {
|
|
12
|
+
import type { TimelineProps } from "./TimelineTypes";
|
|
13
13
|
|
|
14
14
|
interface TimelineGestureOverlayProps {
|
|
15
15
|
drag: DraggedClipState | null;
|
|
16
16
|
scrollRef: React.RefObject<HTMLDivElement | null>;
|
|
17
17
|
pixelsPerSecond: number;
|
|
18
18
|
rowHeight: number;
|
|
19
|
+
contentOrigin: number;
|
|
20
|
+
rowGeometry: TimelineRowGeometry;
|
|
19
21
|
selectedElementId: string | null;
|
|
20
22
|
currentTime: number;
|
|
21
23
|
theme: TimelineTheme;
|
|
22
24
|
getTrackStyle: (tag: string) => TrackVisualStyle;
|
|
23
|
-
renderClipContent?:
|
|
24
|
-
|
|
25
|
-
style: { clip: string; label: string },
|
|
26
|
-
context: TimelineClipRenderContext,
|
|
27
|
-
) => ReactNode;
|
|
28
|
-
renderClipOverlay?: (element: TimelineElement) => ReactNode;
|
|
25
|
+
renderClipContent?: TimelineProps["renderClipContent"];
|
|
26
|
+
renderClipOverlay?: TimelineProps["renderClipOverlay"];
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
/** Stable canvas child that owns the live drag actor independently of source rows. */
|
|
@@ -34,6 +32,8 @@ export const TimelineGestureOverlay = memo(function TimelineGestureOverlay({
|
|
|
34
32
|
scrollRef,
|
|
35
33
|
pixelsPerSecond,
|
|
36
34
|
rowHeight,
|
|
35
|
+
contentOrigin,
|
|
36
|
+
rowGeometry,
|
|
37
37
|
selectedElementId,
|
|
38
38
|
currentTime,
|
|
39
39
|
theme,
|
|
@@ -41,30 +41,68 @@ export const TimelineGestureOverlay = memo(function TimelineGestureOverlay({
|
|
|
41
41
|
renderClipContent,
|
|
42
42
|
renderClipOverlay,
|
|
43
43
|
}: TimelineGestureOverlayProps) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
44
|
+
if (!drag?.started)
|
|
45
|
+
return <div data-timeline-gesture-overlay className="absolute inset-0 pointer-events-none" />;
|
|
46
|
+
const element = getRenderedTimelineElement({
|
|
47
|
+
element: drag.element,
|
|
48
|
+
draggedElementId: drag.element.key ?? drag.element.id,
|
|
49
|
+
previewStart: drag.previewStart,
|
|
50
|
+
previewTrack: drag.previewTrack,
|
|
51
|
+
});
|
|
52
|
+
let position = getTimelineDragOverlayPosition(drag, scrollRef.current);
|
|
53
|
+
const insertRow = drag.insertRow;
|
|
54
|
+
if (insertRow !== null)
|
|
55
|
+
position = {
|
|
56
|
+
left: contentOrigin + drag.previewStart * pixelsPerSecond,
|
|
57
|
+
top: rowGeometry.getRowTop(insertRow) + CLIP_Y,
|
|
58
|
+
};
|
|
59
|
+
const clipWidth = Math.max(element.duration * pixelsPerSecond, 4);
|
|
60
|
+
const viewport = scrollRef.current;
|
|
61
|
+
let labelLeft = clipWidth + 10;
|
|
62
|
+
if (
|
|
63
|
+
position &&
|
|
64
|
+
viewport &&
|
|
65
|
+
position.left + labelLeft + 100 > viewport.scrollLeft + viewport.clientWidth
|
|
66
|
+
) {
|
|
67
|
+
labelLeft = -100;
|
|
68
|
+
if (position.left + labelLeft < viewport.scrollLeft + contentOrigin)
|
|
69
|
+
labelLeft = Math.max(0, Math.min(clipWidth - 100, drag.pointerOffsetX));
|
|
70
|
+
}
|
|
54
71
|
return (
|
|
55
72
|
<div data-timeline-gesture-overlay className="absolute inset-0 pointer-events-none">
|
|
56
|
-
{
|
|
73
|
+
{position && (
|
|
57
74
|
<div
|
|
58
75
|
data-timeline-gesture-actor={element.key ?? element.id}
|
|
59
76
|
className="absolute"
|
|
60
77
|
style={{
|
|
61
78
|
top: position.top,
|
|
62
79
|
left: position.left,
|
|
63
|
-
width:
|
|
80
|
+
width: clipWidth,
|
|
64
81
|
height: rowHeight,
|
|
65
82
|
zIndex: 40,
|
|
66
83
|
}}
|
|
67
84
|
>
|
|
85
|
+
{insertRow !== null && (
|
|
86
|
+
<span
|
|
87
|
+
data-timeline-new-track-label
|
|
88
|
+
role="status"
|
|
89
|
+
className="absolute whitespace-nowrap"
|
|
90
|
+
style={{
|
|
91
|
+
left: labelLeft,
|
|
92
|
+
top: (rowHeight - 22) / 2,
|
|
93
|
+
height: 22,
|
|
94
|
+
padding: "2px 8px",
|
|
95
|
+
borderRadius: 999,
|
|
96
|
+
fontSize: 11,
|
|
97
|
+
color: "var(--timeline-accent)",
|
|
98
|
+
background: theme.rowBackground,
|
|
99
|
+
border: "1px solid var(--timeline-accent)",
|
|
100
|
+
zIndex: 25,
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
+ New track<span className="sr-only">, before track {insertRow + 1}</span>
|
|
104
|
+
</span>
|
|
105
|
+
)}
|
|
68
106
|
<TimelineClip
|
|
69
107
|
el={{ ...element, start: 0 }}
|
|
70
108
|
pps={pixelsPerSecond}
|