mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
fix: preserve negative start times during timeline drag
This commit is contained in:
@@ -297,11 +297,12 @@ export function useElementInteraction({
|
|||||||
zoomLevel,
|
zoomLevel,
|
||||||
scrollLeft,
|
scrollLeft,
|
||||||
});
|
});
|
||||||
const adjustedTime = Math.max(
|
const adjustedTime =
|
||||||
0,
|
mouseTime - pendingDragRef.current.clickOffsetTime;
|
||||||
mouseTime - pendingDragRef.current.clickOffsetTime,
|
const snappedTime = snapTimeToFrame({
|
||||||
);
|
time: adjustedTime,
|
||||||
const snappedTime = snapTimeToFrame({ time: adjustedTime, fps: activeProject.settings.fps });
|
fps: activeProject.settings.fps,
|
||||||
|
});
|
||||||
startDrag({
|
startDrag({
|
||||||
...pendingDragRef.current,
|
...pendingDragRef.current,
|
||||||
initialCurrentTime: snappedTime,
|
initialCurrentTime: snappedTime,
|
||||||
@@ -342,7 +343,7 @@ export function useElementInteraction({
|
|||||||
zoomLevel,
|
zoomLevel,
|
||||||
scrollLeft,
|
scrollLeft,
|
||||||
});
|
});
|
||||||
const adjustedTime = Math.max(0, mouseTime - dragState.clickOffsetTime);
|
const adjustedTime = mouseTime - dragState.clickOffsetTime;
|
||||||
const fps = activeProject.settings.fps;
|
const fps = activeProject.settings.fps;
|
||||||
const frameSnappedTime = snapTimeToFrame({ time: adjustedTime, fps });
|
const frameSnappedTime = snapTimeToFrame({ time: adjustedTime, fps });
|
||||||
|
|
||||||
@@ -455,6 +456,18 @@ export function useElementInteraction({
|
|||||||
onSnapPointChange?.(null);
|
onSnapPointChange?.(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const movingElement =
|
||||||
|
sourceTrack.elements.find(({ id }) => id === dragState.elementId) ?? null;
|
||||||
|
if (
|
||||||
|
movingElement &&
|
||||||
|
!dropTarget.isNewTrack &&
|
||||||
|
tracks[dropTarget.trackIndex]?.id === dragState.trackId &&
|
||||||
|
snappedTime === movingElement.startTime
|
||||||
|
) {
|
||||||
|
endDrag();
|
||||||
|
onSnapPointChange?.(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (dropTarget.isNewTrack) {
|
if (dropTarget.isNewTrack) {
|
||||||
const newTrackId = generateUUID();
|
const newTrackId = generateUUID();
|
||||||
|
|||||||
Reference in New Issue
Block a user