diff options
| author | Maze <167211895+mazeincoding@users.noreply.github.com> | 2025-07-17 13:02:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 13:02:30 +0200 |
| commit | 9bf5ce399c98911338f47c89c31992e7e91a848d (patch) | |
| tree | 48bd51992b723eca50803f36071cb43b21863126 /apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx | |
| parent | 7d4cbca1190edc12ff9ae17029613b77b08436e0 (diff) | |
| parent | 167f366c6d791dfc054d64f50e83828960668e55 (diff) | |
| download | opencut-9bf5ce399c98911338f47c89c31992e7e91a848d.tar.gz | |
Merge pull request #324 from simonorzel26/feat/refactor-timeline
feat(web): timeline refactor and horizontal + vertical scrolling
Diffstat (limited to 'apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx')
| -rw-r--r-- | apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx b/apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx new file mode 100644 index 00000000..8036b96c --- /dev/null +++ b/apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx @@ -0,0 +1,32 @@ +import { useEffect } from "react"; + +export interface TimelineWheelHandlerProps { + timelineRef: React.RefObject<HTMLDivElement>; + isInTimeline: boolean; + handleWheel: (e: React.WheelEvent) => void; +} + +export function useTimelineWheelHandler({ + timelineRef, + isInTimeline, + handleWheel, +}: TimelineWheelHandlerProps) { + useEffect(() => { + const timelineContainer = timelineRef.current; + if (!timelineContainer || !isInTimeline) return; + + const handleWheelCapture = (e: WheelEvent) => { + handleWheel(e as any); + }; + + timelineContainer.addEventListener("wheel", handleWheelCapture, { + passive: false, + }); + + return () => { + timelineContainer.removeEventListener("wheel", handleWheelCapture); + }; + }, [handleWheel, isInTimeline, timelineRef]); + + return null; +} |
