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

This commit is contained in:
braks
2022-10-07 22:55:38 +02:00
committed by Braks
parent de6220b3b3
commit a29d7c86f0
3 changed files with 17 additions and 11 deletions
+1
View File
@@ -67,6 +67,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
id: node.id, id: node.id,
type: 'position', type: 'position',
dragging, dragging,
from: node.from,
} }
if (changed) { if (changed) {
+2
View File
@@ -9,6 +9,7 @@ export interface NodeDragItem {
// distance from the mouse cursor to the node when start dragging // distance from the mouse cursor to the node when start dragging
distance: XYPosition distance: XYPosition
dimensions: Dimensions dimensions: Dimensions
from: XYPosition
extent?: Node['extent'] extent?: Node['extent']
parentNode?: string parentNode?: string
} }
@@ -25,6 +26,7 @@ export interface NodePositionChange {
type: 'position' type: 'position'
position: XYPosition position: XYPosition
computedPosition: XYPosition computedPosition: XYPosition
from: XYPosition
dragging: boolean dragging: boolean
} }
+14 -11
View File
@@ -23,17 +23,20 @@ export function getDragItems(
): NodeDragItem[] { ): NodeDragItem[] {
return nodes return nodes
.filter((n) => (n.selected || n.id === nodeId) && (!n.parentNode || !isParentSelected(n, getNode))) .filter((n) => (n.selected || n.id === nodeId) && (!n.parentNode || !isParentSelected(n, getNode)))
.map((n) => ({ .map((n) =>
id: n.id, markRaw({
position: n.computedPosition || { x: 0, y: 0, z: 0 }, id: n.id,
distance: { position: n.computedPosition || { x: 0, y: 0, z: 0 },
x: mousePos.x - n.computedPosition?.x || 0, distance: {
y: mousePos.y - n.computedPosition?.y || 0, x: mousePos.x - n.computedPosition?.x || 0,
}, y: mousePos.y - n.computedPosition?.y || 0,
extent: n.extent, },
parentNode: n.parentNode, from: n.computedPosition,
dimensions: n.dimensions, extent: n.extent,
})) parentNode: n.parentNode,
dimensions: n.dimensions,
}),
)
} }
export function getEventHandlerParams({ export function getEventHandlerParams({