feat(nodes): add from position to position change event
This commit is contained in:
@@ -67,6 +67,7 @@ export default (state: State, getters: ComputedGetters): Actions => {
|
||||
id: node.id,
|
||||
type: 'position',
|
||||
dragging,
|
||||
from: node.from,
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user