mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
feat: enhance snapping functionality by adding snap point handling in Timeline component
This commit is contained in:
@@ -55,7 +55,7 @@ import {
|
|||||||
import { SelectionBox } from "./selection-box";
|
import { SelectionBox } from "./selection-box";
|
||||||
import { useSelectionBox } from "@/hooks/use-selection-box";
|
import { useSelectionBox } from "@/hooks/use-selection-box";
|
||||||
import { SnapIndicator } from "./snap-indicator";
|
import { SnapIndicator } from "./snap-indicator";
|
||||||
import { useTimelineSnapping } from "@/hooks/use-timeline-snapping";
|
import { useTimelineSnapping, SnapPoint } from "@/hooks/use-timeline-snapping";
|
||||||
import type { DragData, TimelineTrack } from "@/types/timeline";
|
import type { DragData, TimelineTrack } from "@/types/timeline";
|
||||||
import {
|
import {
|
||||||
getTrackHeight,
|
getTrackHeight,
|
||||||
@@ -172,9 +172,16 @@ export function Timeline() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Calculate snap indicator state
|
// Calculate snap indicator state
|
||||||
const [currentSnapPoint, setCurrentSnapPoint] = useState<any>(null);
|
const [currentSnapPoint, setCurrentSnapPoint] = useState<SnapPoint | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
const showSnapIndicator =
|
const showSnapIndicator =
|
||||||
dragState.isDragging && snappingEnabled && currentSnapPoint;
|
dragState.isDragging && snappingEnabled && currentSnapPoint !== null;
|
||||||
|
|
||||||
|
// Callback to handle snap point changes from TimelineTrackContent
|
||||||
|
const handleSnapPointChange = useCallback((snapPoint: SnapPoint | null) => {
|
||||||
|
setCurrentSnapPoint(snapPoint);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Timeline content click to seek handler
|
// Timeline content click to seek handler
|
||||||
const handleTimelineContentClick = useCallback(
|
const handleTimelineContentClick = useCallback(
|
||||||
@@ -1113,6 +1120,7 @@ export function Timeline() {
|
|||||||
<TimelineTrackContent
|
<TimelineTrackContent
|
||||||
track={track}
|
track={track}
|
||||||
zoomLevel={zoomLevel}
|
zoomLevel={zoomLevel}
|
||||||
|
onSnapPointChange={handleSnapPointChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ContextMenuTrigger>
|
</ContextMenuTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user