summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks/use-timeline-zoom-actions.ts
diff options
context:
space:
mode:
authorleimingsheng <leimingsheng@58.com>2025-07-21 19:15:52 +0800
committerleimingsheng <leimingsheng@58.com>2025-07-21 19:15:52 +0800
commitd6724e2552d14140017b194e7020252bda73751a (patch)
tree0b0b400b7933e21ad911cb2366b1806ff2e35a64 /apps/web/src/hooks/use-timeline-zoom-actions.ts
parent263f14ef2a83b0cc78189f764b0c1859fa392539 (diff)
downloadopencut-d6724e2552d14140017b194e7020252bda73751a.tar.gz
feat: init timeline zoom
Diffstat (limited to 'apps/web/src/hooks/use-timeline-zoom-actions.ts')
-rw-r--r--apps/web/src/hooks/use-timeline-zoom-actions.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/web/src/hooks/use-timeline-zoom-actions.ts b/apps/web/src/hooks/use-timeline-zoom-actions.ts
new file mode 100644
index 00000000..85003684
--- /dev/null
+++ b/apps/web/src/hooks/use-timeline-zoom-actions.ts
@@ -0,0 +1,37 @@
+"use client";
+
+import { useActionHandler } from "@/constants/actions";
+
+interface UseTimelineZoomActionsProps {
+ zoomLevel: number;
+ setZoomLevel: (zoomLevel: number | ((prev: number) => number)) => void;
+ onFitToWindow?: () => void;
+}
+
+export function useTimelineZoomActions({
+ zoomLevel,
+ setZoomLevel,
+ onFitToWindow,
+}: UseTimelineZoomActionsProps) {
+ // Zoom in action
+ useActionHandler("zoom-in", () => {
+ setZoomLevel((prev) => Math.min(5, prev + 0.2));
+ });
+
+ // Zoom out action
+ useActionHandler("zoom-out", () => {
+ setZoomLevel((prev) => Math.max(0.1, prev - 0.2));
+ });
+
+ // Reset zoom action
+ useActionHandler("zoom-reset", () => {
+ setZoomLevel(1);
+ });
+
+ // Fit to window action
+ useActionHandler("zoom-fit", () => {
+ if (onFitToWindow) {
+ onFitToWindow();
+ }
+ });
+}