feat(nodes): add from position to position change event

This commit is contained in:
braks
2022-10-06 23:21:16 +02:00
committed by Braks
parent de6220b3b3
commit a29d7c86f0
3 changed files with 17 additions and 11 deletions

View File

@@ -67,6 +67,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
id: node.id,
type: 'position',
dragging,
from: node.from,
}
if (changed) {

View File

@@ -9,6 +9,7 @@ export interface NodeDragItem {
// distance from the mouse cursor to the node when start dragging
distance: XYPosition
dimensions: Dimensions
from: XYPosition
extent?: Node['extent']
parentNode?: string
}
@@ -25,6 +26,7 @@ export interface NodePositionChange {
type: 'position'
position: XYPosition
computedPosition: XYPosition
from: XYPosition
dragging: boolean
}

View File

@@ -23,17 +23,20 @@ export function getDragItems(
): NodeDragItem[] {
return nodes
.filter((n) => (n.selected || n.id === nodeId) && (!n.parentNode || !isParentSelected(n, getNode)))
.map((n) => ({
id: n.id,
position: n.computedPosition || { x: 0, y: 0, z: 0 },
distance: {
x: mousePos.x - n.computedPosition?.x || 0,
y: mousePos.y - n.computedPosition?.y || 0,
},
extent: n.extent,
parentNode: n.parentNode,
dimensions: n.dimensions,
}))
.map((n) =>
markRaw({
id: n.id,
position: n.computedPosition || { x: 0, y: 0, z: 0 },
distance: {
x: mousePos.x - n.computedPosition?.x || 0,
y: mousePos.y - n.computedPosition?.y || 0,
},
from: n.computedPosition,
extent: n.extent,
parentNode: n.parentNode,
dimensions: n.dimensions,
}),
)
}
export function getEventHandlerParams({