summaryrefslogtreecommitdiff
path: root/apps/web/src/timeline/bookmarks
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/timeline/bookmarks')
-rw-r--r--apps/web/src/timeline/bookmarks/components/bookmarks.tsx4
-rw-r--r--apps/web/src/timeline/bookmarks/hooks/use-bookmark-drag.ts23
-rw-r--r--apps/web/src/timeline/bookmarks/snap-source.ts3
-rw-r--r--apps/web/src/timeline/bookmarks/utils.ts5
4 files changed, 16 insertions, 19 deletions
diff --git a/apps/web/src/timeline/bookmarks/components/bookmarks.tsx b/apps/web/src/timeline/bookmarks/components/bookmarks.tsx
index 0f0710cb..43ba4ffc 100644
--- a/apps/web/src/timeline/bookmarks/components/bookmarks.tsx
+++ b/apps/web/src/timeline/bookmarks/components/bookmarks.tsx
@@ -7,7 +7,6 @@ import type { BookmarkDragState } from "../hooks/use-bookmark-drag";
import { DEFAULT_TIMELINE_BOOKMARK_COLOR } from "@/timeline/components/theme";
import { TIMELINE_BOOKMARK_ROW_HEIGHT_PX } from "@/timeline/components/layout";
import { DEFAULT_FPS } from "@/fps/defaults";
-import { snappedSeekTime } from "opencut-wasm";
import {
ArrowTurnBackwardIcon,
Delete02Icon,
@@ -30,6 +29,7 @@ import {
type MediaTime,
mediaTimeFromSeconds,
mediaTimeToSeconds,
+ snapSeekMediaTime,
subMediaTime,
ZERO_MEDIA_TIME,
} from "@/wasm";
@@ -51,7 +51,7 @@ function seekToBookmarkTime({
const activeProject = editor.project.getActive();
const duration = editor.timeline.getTotalDuration();
const rate = activeProject?.settings.fps ?? DEFAULT_FPS;
- const snappedTime = (snappedSeekTime({ time, duration, rate }) ?? time) as MediaTime;
+ const snappedTime = snapSeekMediaTime({ time, duration, fps: rate });
editor.playback.seek({ time: snappedTime });
}
diff --git a/apps/web/src/timeline/bookmarks/hooks/use-bookmark-drag.ts b/apps/web/src/timeline/bookmarks/hooks/use-bookmark-drag.ts
index 8996330b..343fda80 100644
--- a/apps/web/src/timeline/bookmarks/hooks/use-bookmark-drag.ts
+++ b/apps/web/src/timeline/bookmarks/hooks/use-bookmark-drag.ts
@@ -8,7 +8,6 @@ import {
import { useEditor } from "@/editor/use-editor";
import { useShiftKey } from "@/hooks/use-shift-key";
import { TIMELINE_DRAG_THRESHOLD_PX } from "@/timeline/components/interaction";
-import { roundToFrame } from "opencut-wasm";
import { getMouseTimeFromClientX } from "@/timeline/drag-utils";
import {
buildTimelineSnapPoints,
@@ -21,7 +20,7 @@ import { getElementEdgeSnapPoints } from "@/timeline/element-snap-source";
import { getPlayheadSnapPoints } from "@/timeline/playhead-snap-source";
import { getAnimationKeyframeSnapPointsForTimeline } from "@/animation/timeline-snap-points";
import type { Bookmark } from "@/timeline";
-import { type MediaTime, ZERO_MEDIA_TIME } from "@/wasm";
+import { roundFrameTime, type MediaTime, ZERO_MEDIA_TIME } from "@/wasm";
export interface BookmarkDragState {
isDragging: boolean;
@@ -117,7 +116,7 @@ export function useBookmarkDrag({
maxSnapDistance: getTimelineSnapThresholdInTicks({ zoomLevel }),
});
return {
- snappedTime: result.snappedTime as MediaTime,
+ snappedTime: result.snappedTime,
snapPoint: result.snapPoint,
};
},
@@ -165,12 +164,10 @@ export function useBookmarkDrag({
});
const clampedTime =
mouseTime > duration ? duration : mouseTime;
- const frameSnappedTime = (
- roundToFrame({
- time: clampedTime,
- rate: activeProject.settings.fps,
- }) ?? clampedTime
- ) as MediaTime;
+ const frameSnappedTime = roundFrameTime({
+ time: clampedTime,
+ fps: activeProject.settings.fps,
+ });
const { snappedTime: initialTime } = getSnapResult({
rawTime: frameSnappedTime,
excludeBookmarkTime: bookmarkTime,
@@ -199,10 +196,10 @@ export function useBookmarkDrag({
});
const clampedTime =
mouseTime > duration ? duration : mouseTime;
- const frameSnappedTime = (
- roundToFrame({ time: clampedTime, rate: activeProject.settings.fps }) ??
- clampedTime
- ) as MediaTime;
+ const frameSnappedTime = roundFrameTime({
+ time: clampedTime,
+ fps: activeProject.settings.fps,
+ });
const snapResult = getSnapResult({
rawTime: frameSnappedTime,
excludeBookmarkTime: dragState.bookmarkTime,
diff --git a/apps/web/src/timeline/bookmarks/snap-source.ts b/apps/web/src/timeline/bookmarks/snap-source.ts
index 32a84baa..64d0c3c3 100644
--- a/apps/web/src/timeline/bookmarks/snap-source.ts
+++ b/apps/web/src/timeline/bookmarks/snap-source.ts
@@ -1,12 +1,13 @@
import type { Bookmark } from "@/timeline";
import type { SnapPoint } from "@/timeline/snapping";
+import type { MediaTime } from "@/wasm";
export function getBookmarkSnapPoints({
bookmarks,
excludeBookmarkTime,
}: {
bookmarks: Bookmark[];
- excludeBookmarkTime?: number;
+ excludeBookmarkTime?: MediaTime;
}): SnapPoint[] {
return bookmarks.flatMap((bookmark) => {
if (excludeBookmarkTime != null && bookmark.time === excludeBookmarkTime) {
diff --git a/apps/web/src/timeline/bookmarks/utils.ts b/apps/web/src/timeline/bookmarks/utils.ts
index 52e5aa60..702e66c3 100644
--- a/apps/web/src/timeline/bookmarks/utils.ts
+++ b/apps/web/src/timeline/bookmarks/utils.ts
@@ -1,7 +1,6 @@
import type { Bookmark } from "@/timeline";
import type { FrameRate } from "opencut-wasm";
-import { roundToFrame } from "opencut-wasm";
-import { addMediaTime, type MediaTime } from "@/wasm";
+import { addMediaTime, roundFrameTime, type MediaTime } from "@/wasm";
function bookmarkTimeEqual({
bookmarkTime,
@@ -114,7 +113,7 @@ export function getFrameTime({
time: MediaTime;
fps: FrameRate;
}): MediaTime {
- return (roundToFrame({ time, rate: fps }) ?? time) as MediaTime;
+ return roundFrameTime({ time, fps });
}
export function getBookmarkAtTime({