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,
|
id: node.id,
|
||||||
type: 'position',
|
type: 'position',
|
||||||
dragging,
|
dragging,
|
||||||
|
from: node.from,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user