This commit is contained in:
Aria Minaei 2021-09-17 17:23:56 +02:00
parent 4eaba1e8d5
commit af336a0a82
4 changed files with 11 additions and 6 deletions

View file

@ -181,6 +181,7 @@ function useDragKeyframe(node: HTMLDivElement | null, props: IProps) {
pathToProp: leaf.pathToProp, pathToProp: leaf.pathToProp,
trackId: leaf.trackId, trackId: leaf.trackId,
keyframeId: props.keyframe.id, keyframeId: props.keyframe.id,
domNode: node!,
positionAtStartOfDrag: positionAtStartOfDrag:
props.trackData.keyframes[props.index].position, props.trackData.keyframes[props.index].position,
}) })

View file

@ -164,6 +164,7 @@ function useDragKeyframe(
pathToProp: leaf.pathToProp, pathToProp: leaf.pathToProp,
trackId: leaf.trackId, trackId: leaf.trackId,
keyframeId: props.keyframe.id, keyframeId: props.keyframe.id,
domNode: node!,
positionAtStartOfDrag: positionAtStartOfDrag:
props.trackData.keyframes[props.index].position, props.trackData.keyframes[props.index].position,
}) })

View file

@ -212,12 +212,14 @@ namespace utils {
tempTransaction = undefined tempTransaction = undefined
} }
const snapTarget = event.composedPath().find( const snapTarget = event
(el): el is Element => .composedPath()
el instanceof Element && .find(
// el !== node && (el): el is Element =>
el.hasAttribute('data-pos'), el instanceof Element &&
) el !== origin.domNode &&
el.hasAttribute('data-pos'),
)
if (snapTarget) { if (snapTarget) {
const snapPos = parseFloat(snapTarget.getAttribute('data-pos')!) const snapPos = parseFloat(snapTarget.getAttribute('data-pos')!)

View file

@ -56,6 +56,7 @@ export type DopeSheetSelection = {
trackId: string trackId: string
keyframeId: string keyframeId: string
positionAtStartOfDrag: number positionAtStartOfDrag: number
domNode: Element
}, },
): Parameters<typeof useDrag>[1] ): Parameters<typeof useDrag>[1]
delete(): void delete(): void