From 503e73861768aa220ffed32d5c723c5bdecbafed Mon Sep 17 00:00:00 2001 From: GeorgeCaoJ Date: Tue, 24 Jun 2025 14:25:29 +0800 Subject: [PATCH 1/2] feat: add context menu in tracks and zooming in timeline --- apps/web/src/components/editor/timeline.tsx | 52 ++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index ce81f9e..6c4063f 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -49,6 +49,7 @@ export function Timeline() { const [zoomLevel, setZoomLevel] = useState(1); const dragCounterRef = useRef(0); const timelineRef = useRef(null); + const [isInTimeline, setIsInTimeline] = useState(false); // Unified context menu state const [contextMenu, setContextMenu] = useState<{ @@ -477,10 +478,29 @@ export function Timeline() { toast.success("Deleted selected clip(s)"); }; + + // Prevent explorer zooming in/out when in timeline + useEffect(() => { + const preventZoom = (e: WheelEvent) => { + if (isInTimeline && (e.ctrlKey || e.metaKey)) { + e.preventDefault(); + } + }; + + document.addEventListener('wheel', preventZoom, { passive: false }); + + return () => { + document.removeEventListener('wheel', preventZoom); + }; + }, [isInTimeline]); + return (
setIsInTimeline(true)} + onMouseLeave={() => setIsInTimeline(false)} + onWheel={handleWheel} > {/* Show overlay when dragging media over the timeline */} {isDragOver && ( @@ -758,25 +778,35 @@ export function Timeline() {
{ + e.preventDefault(); + setContextMenu({ + type: 'track', + trackId: track.id, + x: e.clientX, + y: e.clientY, + }); + }} > -
+
- + {track.name} - {track.muted && ( - - Muted - - )}
+ {track.muted && ( + + Muted + + )}
))}
From 5bba941dbc330a40030411c8603e0aad61e56bfa Mon Sep 17 00:00:00 2001 From: GeorgeCaoJ Date: Tue, 24 Jun 2025 17:22:05 +0800 Subject: [PATCH 2/2] fix: wheel zooming in timeline tracks content --- apps/web/src/components/editor/timeline.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 6c4063f..5a2b05b 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -482,7 +482,8 @@ export function Timeline() { // Prevent explorer zooming in/out when in timeline useEffect(() => { const preventZoom = (e: WheelEvent) => { - if (isInTimeline && (e.ctrlKey || e.metaKey)) { + // if (isInTimeline && (e.ctrlKey || e.metaKey)) { + if (isInTimeline && (e.ctrlKey || e.metaKey) && timelineRef.current?.contains(e.target as Node)) { e.preventDefault(); } }; @@ -825,7 +826,6 @@ export function Timeline() { }} onClick={handleTimelineAreaClick} onMouseDown={handleTimelineMouseDown} - onWheel={handleWheel} > {tracks.length === 0 ? (