diff options
| author | Simon Orzel <simonorzel@gmail.com> | 2025-07-17 01:59:39 +0200 |
|---|---|---|
| committer | Simon Orzel <simonorzel@gmail.com> | 2025-07-17 01:59:39 +0200 |
| commit | 9fa9f406fe2722cec1e0d65d9b3868acd1e99f87 (patch) | |
| tree | 8d6eebabf99941c970a36dc271da9e9d63128f42 /apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx | |
| parent | 0d2894feda369d518f650ac2c832edb0bb8b9254 (diff) | |
| download | opencut-9fa9f406fe2722cec1e0d65d9b3868acd1e99f87.tar.gz | |
feat: splits working code
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 | 33 |
1 files changed, 33 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..430d65ae --- /dev/null +++ b/apps/web/src/components/editor/timeline/timeline-wheel-handler.tsx @@ -0,0 +1,33 @@ +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) { + // Add wheel event listeners with passive: false to allow preventDefault + useEffect(() => { + const timelineContainer = timelineRef.current; + if (!timelineContainer || !isInTimeline) return; + + const handleWheelCapture = (e: WheelEvent) => { + // Call the existing handleWheel function + handleWheel(e as any); + }; + + // Add wheel event listener with passive: false to allow preventDefault + timelineContainer.addEventListener("wheel", handleWheelCapture, { passive: false }); + + return () => { + timelineContainer.removeEventListener("wheel", handleWheelCapture); + }; + }, [handleWheel, isInTimeline, timelineRef]); + + return null; +} |
