diff --git a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/Dot.tsx b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/Dot.tsx index c2261e3..98fc2d3 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/Dot.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/BasicKeyframedTrack/KeyframeEditor/Dot.tsx @@ -118,6 +118,7 @@ function useDragKeyframe(node: HTMLDivElement | null, props: IProps) { let toUnitSpace: SequenceEditorPanelLayout['scaledSpace']['toUnitSpace'] let tempTransaction: CommitOrDiscard | undefined let propsAtStartOfDrag: IProps + let startingLayout: SequenceEditorPanelLayout let selectionDragHandlers: | ReturnType @@ -148,21 +149,21 @@ function useDragKeyframe(node: HTMLDivElement | null, props: IProps) { selectionDragHandlers.onDrag(dx, dy, event) return } - const delta = toUnitSpace(dx) + const original = + propsAtStartOfDrag.trackData.keyframes[propsAtStartOfDrag.index] + const deltaPos = toUnitSpace(dx) + const newPosBeforeSnapping = Math.max(original.position + deltaPos, 0) if (tempTransaction) { tempTransaction.discard() tempTransaction = undefined } tempTransaction = getStudio()!.tempTransaction(({stateEditors}) => { - stateEditors.coreByProject.historic.sheetsById.sequence.transformKeyframes( + stateEditors.coreByProject.historic.sheetsById.sequence.replaceKeyframes( { ...propsAtStartOfDrag.leaf.sheetObject.address, trackId: propsAtStartOfDrag.leaf.trackId, - keyframeIds: [propsAtStartOfDrag.keyframe.id], - translate: delta, - scale: 1, - origin: 0, + keyframes: [{...original, position: newPosBeforeSnapping}], }, ) })