Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Stop the timeline chrome being selected by a drag

Bittid71c205d21d3
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index 7c77bdb..35b19aa 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -223,6 +223,14 @@ export function TimelineView({ config, folderPath, onChange, onMeasured, onOpenG
return () => grid.removeEventListener("wheel", onWheel);
}, [duration, config.settings.frameRate]);
+ /** Any highlight the press just painted, undone. The chrome down here is not
+ * selectable at all (see .pro-timeline), but a gesture can begin on a clip
+ * and travel over the panels above, and a selection that was already in
+ * progress goes on extending under the pointer. Clearing it at the start of
+ * a gesture is the difference between dragging a clip and dragging a clip
+ * through a blue smear. */
+ const dropSelection = () => window.getSelection?.()?.removeAllRanges();
+
/** Turn a pointer position on the ruler into a playhead position. A ruler
* nothing has laid out has no scale, so it is left alone rather than
* sending the playhead to NaN. */
@@ -494,6 +502,7 @@ export function TimelineView({ config, folderPath, onChange, onMeasured, onOpenG
// with, and a drag measured against a zero-width lane would put the clip at
// an arbitrary place on the ruler. The clip still selects.
if (!rect || rect.width <= 0) { setSelectedId(clip.id); return; }
+ dropSelection();
const msPerPx = duration / rect.width;
dragRef.current = {
clipId: clip.id,
@@ -583,7 +592,7 @@ export function TimelineView({ config, folderPath, onChange, onMeasured, onOpenG
};
return (
- <div className={`timeline-view ${dragging ? "timeline-view--dragging" : ""}`} tabIndex={0} onKeyDown={(event) => {
+ <div className={`timeline-view ${dragging ? "timeline-view--dragging" : ""} ${scrubbing ? "timeline-view--scrubbing" : ""}`} tabIndex={0} onKeyDown={(event) => {
/* Delete works from the view itself and from a focused clip — the clip IS
the thing being deleted, and having to leave it first to press the key
is the kind of rule only the code knows. It deliberately does NOT fire
@@ -785,6 +794,7 @@ export function TimelineView({ config, folderPath, onChange, onMeasured, onOpenG
className="time-ruler"
onPointerDown={(event) => {
event.currentTarget.setPointerCapture?.(event.pointerId);
+ dropSelection();
setPlaying(false);
setScrubbing(true);
scrubTo(event.currentTarget, event.clientX);
diff --git a/src/styles/timeline.css b/src/styles/timeline.css
index e4e403e..fbd9ff2 100644
--- a/src/styles/timeline.css
+++ b/src/styles/timeline.css
@@ -814,6 +814,20 @@
display: grid;
grid-template-rows: var(--control-lg) minmax(0, 1fr);
background: var(--panel);
+ /* None of this is text anyone reads by selecting it: the heading, the
+ timecode, the format, the ruler's numbers and the clips' own labels are
+ chrome. Every gesture down here is a drag — scrubbing the ruler, moving a
+ clip, trimming one — and a drag over selectable chrome paints it blue.
+ Turned off permanently rather than for the duration of a drag, because the
+ browser starts a selection on the press, before a class applied by a
+ re-render can reach the DOM. */
+ user-select: none;
+}
+
+/* Except what really is text being edited: a track's name is typed into, and
+ typing means selecting. */
+.pro-timeline input {
+ user-select: text;
}
/* Three tracks, and the two outer ones are the SAME width whatever they hold —
@@ -1329,10 +1343,17 @@
display: none;
}
-/* Nothing is selectable while a clip is being dragged: a drag across the lanes
- would otherwise paint the whole timeline blue with a text selection. */
-.timeline-view--dragging {
+/* A drag that leaves the timeline is still a drag: the pointer crosses the
+ monitor and the inspector on its way, and those DO hold readable text, so
+ they are frozen for the length of the gesture rather than for good. Scrubbing
+ the ruler counts — the pointer can wander anywhere while the playhead is
+ being pulled along. */
+.timeline-view--dragging,
+.timeline-view--scrubbing {
user-select: none;
+}
+
+.timeline-view--dragging {
cursor: grabbing;
}