blob: 8500368479826537ccc09e8f646a3a753d2985dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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();
}
});
}
|