diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-07-12 12:48:31 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-07-12 12:48:31 +0200 |
| commit | 8545d95070890edfcf76b788ee023f9d510c302d (patch) | |
| tree | b3e1f9bf0bf30a8e748094b0a52c483befd7accf /apps/web/src/hooks/use-timeline-playhead.ts | |
| parent | 0726c27221c5b3aa9a8442b0cf89bd6acd8dfb5a (diff) | |
| download | opencut-8545d95070890edfcf76b788ee023f9d510c302d.tar.gz | |
refactor: add FPS and remove turbopack (yes, fuck you turbopack)
Diffstat (limited to 'apps/web/src/hooks/use-timeline-playhead.ts')
| -rw-r--r-- | apps/web/src/hooks/use-timeline-playhead.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/apps/web/src/hooks/use-timeline-playhead.ts b/apps/web/src/hooks/use-timeline-playhead.ts index 61adaf92..9a82c23f 100644 --- a/apps/web/src/hooks/use-timeline-playhead.ts +++ b/apps/web/src/hooks/use-timeline-playhead.ts @@ -1,3 +1,5 @@ +import { snapTimeToFrame } from "@/constants/timeline-constants";
+import { useProjectStore } from "@/stores/project-store";
import { useState, useEffect, useCallback } from "react";
interface UseTimelinePlayheadProps {
@@ -69,7 +71,11 @@ export function useTimelinePlayhead({ if (!ruler) return;
const rect = ruler.getBoundingClientRect();
const x = e.clientX - rect.left;
- const time = Math.max(0, Math.min(duration, x / (50 * zoomLevel)));
+ const rawTime = Math.max(0, Math.min(duration, x / (50 * zoomLevel)));
+ // Use frame snapping for playhead scrubbing
+ const projectStore = useProjectStore.getState();
+ const projectFps = projectStore.activeProject?.fps || 30;
+ const time = snapTimeToFrame(rawTime, projectFps);
setScrubTime(time);
seek(time); // update video preview in real time
},
|
