mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
fix: keyframe drag bug
This commit is contained in:
@@ -9,7 +9,10 @@ import { useEditor } from "@/hooks/use-editor";
|
|||||||
import { useKeyframeSelection } from "./use-keyframe-selection";
|
import { useKeyframeSelection } from "./use-keyframe-selection";
|
||||||
import { snapTimeToFrame } from "@/lib/time";
|
import { snapTimeToFrame } from "@/lib/time";
|
||||||
import { timelineTimeToSnappedPixels } from "@/lib/timeline";
|
import { timelineTimeToSnappedPixels } from "@/lib/timeline";
|
||||||
import { DRAG_THRESHOLD_PX, TIMELINE_CONSTANTS } from "@/constants/timeline-constants";
|
import {
|
||||||
|
DRAG_THRESHOLD_PX,
|
||||||
|
TIMELINE_CONSTANTS,
|
||||||
|
} from "@/constants/timeline-constants";
|
||||||
import { RetimeKeyframeCommand } from "@/lib/commands/timeline/element/keyframes/retime-keyframe";
|
import { RetimeKeyframeCommand } from "@/lib/commands/timeline/element/keyframes/retime-keyframe";
|
||||||
import { BatchCommand } from "@/lib/commands";
|
import { BatchCommand } from "@/lib/commands";
|
||||||
import type { SelectedKeyframeRef } from "@/types/animation";
|
import type { SelectedKeyframeRef } from "@/types/animation";
|
||||||
@@ -44,6 +47,7 @@ export function useKeyframeDrag({
|
|||||||
const {
|
const {
|
||||||
selectedKeyframes,
|
selectedKeyframes,
|
||||||
isKeyframeSelected,
|
isKeyframeSelected,
|
||||||
|
setKeyframeSelection,
|
||||||
toggleKeyframeSelection,
|
toggleKeyframeSelection,
|
||||||
selectKeyframeRange,
|
selectKeyframeRange,
|
||||||
} = useKeyframeSelection();
|
} = useKeyframeSelection();
|
||||||
@@ -196,6 +200,11 @@ export function useKeyframeDrag({
|
|||||||
const anySelected = keyframes.some((keyframe) =>
|
const anySelected = keyframes.some((keyframe) =>
|
||||||
isKeyframeSelected({ keyframe }),
|
isKeyframeSelected({ keyframe }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!anySelected) {
|
||||||
|
setKeyframeSelection({ keyframes });
|
||||||
|
}
|
||||||
|
|
||||||
const keyframeRefsToTrack = anySelected ? selectedKeyframes : keyframes;
|
const keyframeRefsToTrack = anySelected ? selectedKeyframes : keyframes;
|
||||||
|
|
||||||
pendingDragRef.current = {
|
pendingDragRef.current = {
|
||||||
@@ -204,7 +213,7 @@ export function useKeyframeDrag({
|
|||||||
};
|
};
|
||||||
setIsPendingDrag(true);
|
setIsPendingDrag(true);
|
||||||
},
|
},
|
||||||
[isKeyframeSelected, selectedKeyframes],
|
[isKeyframeSelected, selectedKeyframes, setKeyframeSelection],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeyframeClick = useCallback(
|
const handleKeyframeClick = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user