Keyframe drag snapping
This commit is contained in:
parent
ae66ea90c6
commit
e6bfd999a2
1 changed files with 7 additions and 6 deletions
|
@ -118,6 +118,7 @@ function useDragKeyframe(node: HTMLDivElement | null, props: IProps) {
|
||||||
let toUnitSpace: SequenceEditorPanelLayout['scaledSpace']['toUnitSpace']
|
let toUnitSpace: SequenceEditorPanelLayout['scaledSpace']['toUnitSpace']
|
||||||
let tempTransaction: CommitOrDiscard | undefined
|
let tempTransaction: CommitOrDiscard | undefined
|
||||||
let propsAtStartOfDrag: IProps
|
let propsAtStartOfDrag: IProps
|
||||||
|
let startingLayout: SequenceEditorPanelLayout
|
||||||
|
|
||||||
let selectionDragHandlers:
|
let selectionDragHandlers:
|
||||||
| ReturnType<DopeSheetSelection['getDragHandlers']>
|
| ReturnType<DopeSheetSelection['getDragHandlers']>
|
||||||
|
@ -148,21 +149,21 @@ function useDragKeyframe(node: HTMLDivElement | null, props: IProps) {
|
||||||
selectionDragHandlers.onDrag(dx, dy, event)
|
selectionDragHandlers.onDrag(dx, dy, event)
|
||||||
return
|
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) {
|
if (tempTransaction) {
|
||||||
tempTransaction.discard()
|
tempTransaction.discard()
|
||||||
tempTransaction = undefined
|
tempTransaction = undefined
|
||||||
}
|
}
|
||||||
tempTransaction = getStudio()!.tempTransaction(({stateEditors}) => {
|
tempTransaction = getStudio()!.tempTransaction(({stateEditors}) => {
|
||||||
stateEditors.coreByProject.historic.sheetsById.sequence.transformKeyframes(
|
stateEditors.coreByProject.historic.sheetsById.sequence.replaceKeyframes(
|
||||||
{
|
{
|
||||||
...propsAtStartOfDrag.leaf.sheetObject.address,
|
...propsAtStartOfDrag.leaf.sheetObject.address,
|
||||||
trackId: propsAtStartOfDrag.leaf.trackId,
|
trackId: propsAtStartOfDrag.leaf.trackId,
|
||||||
keyframeIds: [propsAtStartOfDrag.keyframe.id],
|
keyframes: [{...original, position: newPosBeforeSnapping}],
|
||||||
translate: delta,
|
|
||||||
scale: 1,
|
|
||||||
origin: 0,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue