mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
new utility, less duplicated code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useRef } from "react";
|
||||
import type { MutableRefObject, RefObject } from "react";
|
||||
import { TIMELINE_CONSTANTS } from "@/constants/timeline-constants";
|
||||
import { snapTimeToFrame } from "@/lib/time-utils";
|
||||
import { getSnappedSeekTime } from "@/lib/time-utils";
|
||||
import { useEditor } from "../use-editor";
|
||||
|
||||
interface UseTimelineInteractionsProps {
|
||||
@@ -139,7 +139,11 @@ export function useTimelineInteractions({
|
||||
);
|
||||
|
||||
const projectFps = activeProject?.settings.fps || 30;
|
||||
const time = snapTimeToFrame({ time: rawTime, fps: projectFps });
|
||||
const time = getSnappedSeekTime({
|
||||
rawTime,
|
||||
duration,
|
||||
fps: projectFps,
|
||||
});
|
||||
seek(time);
|
||||
},
|
||||
[
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { snapTimeToFrame } from "@/lib/time-utils";
|
||||
import { getSnappedSeekTime } from "@/lib/time-utils";
|
||||
import { useState, useEffect, useCallback, useRef } from "react";
|
||||
import { useEdgeAutoScroll } from "@/hooks/timeline/use-edge-auto-scroll";
|
||||
import { useEditor } from "../use-editor";
|
||||
@@ -89,7 +89,7 @@ export function useTimelinePlayhead({
|
||||
);
|
||||
// use frame snapping for playhead scrubbing
|
||||
const fps = activeProject.settings.fps;
|
||||
const time = snapTimeToFrame({ time: rawTime, fps });
|
||||
const time = getSnappedSeekTime({ rawTime, duration, fps });
|
||||
|
||||
setScrubTime(time);
|
||||
seek(time); // update video preview in real time
|
||||
|
||||
Reference in New Issue
Block a user