summaryrefslogtreecommitdiff
path: root/apps/web/src/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/hooks')
-rw-r--r--apps/web/src/hooks/actions/use-editor-actions.ts2
-rw-r--r--apps/web/src/hooks/timeline/element/use-element-interaction.ts30
-rw-r--r--apps/web/src/hooks/timeline/element/use-element-resize.ts5
3 files changed, 19 insertions, 18 deletions
diff --git a/apps/web/src/hooks/actions/use-editor-actions.ts b/apps/web/src/hooks/actions/use-editor-actions.ts
index 356d0e2b..76f705e9 100644
--- a/apps/web/src/hooks/actions/use-editor-actions.ts
+++ b/apps/web/src/hooks/actions/use-editor-actions.ts
@@ -212,7 +212,6 @@ export function useEditorActions() {
elements: elementsToSplit,
splitTime: currentTime,
retainSide: "right",
- rippleEnabled: rippleEditingEnabled,
});
if (rippleEditingEnabled && rightSideElements.length > 0) {
@@ -263,7 +262,6 @@ export function useEditorActions() {
}
editor.timeline.deleteElements({
elements: selectedElements,
- rippleEnabled: rippleEditingEnabled,
});
},
undefined,
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 193379ed..71ae4704 100644
--- a/apps/web/src/hooks/timeline/element/use-element-interaction.ts
+++ b/apps/web/src/hooks/timeline/element/use-element-interaction.ts
@@ -8,7 +8,6 @@ import {
} from "react";
import { useEditor } from "@/hooks/use-editor";
import { useShiftKey } from "@/hooks/use-shift-key";
-import { useTimelineStore } from "@/stores/timeline-store";
import { useElementSelection } from "@/hooks/timeline/element/use-element-selection";
import { BASE_TIMELINE_PIXELS_PER_SECOND } from "@/lib/timeline/scale";
import { TIMELINE_DRAG_THRESHOLD_PX } from "@/components/editor/panels/timeline/interaction";
@@ -161,7 +160,6 @@ export function useElementInteraction({
onSnapPointChange,
}: UseElementInteractionProps) {
const editor = useEditor();
- const rippleEditingEnabled = useTimelineStore((s) => s.rippleEditingEnabled);
const isShiftHeldRef = useShiftKey();
const tracks = editor.timeline.getTracks();
const {
@@ -299,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,
@@ -344,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 });
@@ -457,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();
@@ -467,7 +478,6 @@ export function useElementInteraction({
elementId: dragState.elementId,
newStartTime: snappedTime,
createTrack: { type: sourceTrack.type, index: dropTarget.trackIndex },
- rippleEnabled: rippleEditingEnabled,
});
selectElement({ trackId: newTrackId, elementId: dragState.elementId });
} else {
@@ -478,7 +488,6 @@ export function useElementInteraction({
targetTrackId: targetTrack.id,
elementId: dragState.elementId,
newStartTime: snappedTime,
- rippleEnabled: rippleEditingEnabled,
});
if (targetTrack.id !== dragState.trackId) {
selectElement({
@@ -509,7 +518,6 @@ export function useElementInteraction({
tracksContainerRef,
tracksScrollRef,
headerRef,
- rippleEditingEnabled,
selectElement,
]);
diff --git a/apps/web/src/hooks/timeline/element/use-element-resize.ts b/apps/web/src/hooks/timeline/element/use-element-resize.ts
index 890820d7..3dd98bea 100644
--- a/apps/web/src/hooks/timeline/element/use-element-resize.ts
+++ b/apps/web/src/hooks/timeline/element/use-element-resize.ts
@@ -45,9 +45,6 @@ export function useTimelineElementResize({
const editor = useEditor();
const isShiftHeldRef = useShiftKey();
const snappingEnabled = useTimelineStore((state) => state.snappingEnabled);
- const rippleEditingEnabled = useTimelineStore(
- (state) => state.rippleEditingEnabled,
- );
const [resizing, setResizing] = useState<ResizeState | null>(null);
const [currentTrimStart, setCurrentTrimStart] = useState(element.trimStart);
@@ -458,7 +455,6 @@ export function useTimelineElementResize({
trimEnd: finalTrimEnd,
startTime: startTimeChanged ? finalStartTime : undefined,
duration: durationChanged ? finalDuration : undefined,
- rippleEnabled: rippleEditingEnabled,
});
}
@@ -471,7 +467,6 @@ export function useTimelineElementResize({
element.id,
onResizeStateChange,
onSnapPointChange,
- rippleEditingEnabled,
]);
useEffect(() => {