summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks/timeline/element
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/hooks/timeline/element')
-rw-r--r--apps/web/src/hooks/timeline/element/use-element-interaction.ts25
1 files changed, 19 insertions, 6 deletions
diff --git a/apps/web/src/hooks/timeline/element/use-element-interaction.ts b/apps/web/src/hooks/timeline/element/use-element-interaction.ts
index fcc821fe..71ae4704 100644
--- a/apps/web/src/hooks/timeline/element/use-element-interaction.ts
+++ b/apps/web/src/hooks/timeline/element/use-element-interaction.ts
@@ -297,11 +297,12 @@ export function useElementInteraction({
zoomLevel,
scrollLeft,
});
- const adjustedTime = Math.max(
- 0,
- mouseTime - pendingDragRef.current.clickOffsetTime,
- );
- const snappedTime = snapTimeToFrame({ time: adjustedTime, fps: activeProject.settings.fps });
+ const adjustedTime =
+ mouseTime - pendingDragRef.current.clickOffsetTime;
+ const snappedTime = snapTimeToFrame({
+ time: adjustedTime,
+ fps: activeProject.settings.fps,
+ });
startDrag({
...pendingDragRef.current,
initialCurrentTime: snappedTime,
@@ -342,7 +343,7 @@ export function useElementInteraction({
zoomLevel,
scrollLeft,
});
- const adjustedTime = Math.max(0, mouseTime - dragState.clickOffsetTime);
+ const adjustedTime = mouseTime - dragState.clickOffsetTime;
const fps = activeProject.settings.fps;
const frameSnappedTime = snapTimeToFrame({ time: adjustedTime, fps });
@@ -455,6 +456,18 @@ export function useElementInteraction({
onSnapPointChange?.(null);
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) {
const newTrackId = generateUUID();