refactor(xydrag): cleanup
This commit is contained in:
@@ -120,8 +120,8 @@ export type NodeDragItem = {
|
||||
// distance from the mouse cursor to the node when start dragging
|
||||
distance: XYPosition;
|
||||
measured: {
|
||||
width?: number;
|
||||
height?: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
internals: {
|
||||
positionAbsolute: XYPosition;
|
||||
|
||||
@@ -144,10 +144,10 @@ export function XYDrag<OnNodeDrag extends (e: any, nodes: any, node: any) => voi
|
||||
if (dragItems.size > 1 && nodeExtent && !dragItem.extent) {
|
||||
const { positionAbsolute } = dragItem.internals;
|
||||
const x1 = positionAbsolute.x - nodesBox.x + nodeExtent[0][0];
|
||||
const x2 = positionAbsolute.x + (dragItem.measured?.width ?? 0) - nodesBox.x2 + nodeExtent[1][0];
|
||||
const x2 = positionAbsolute.x + dragItem.measured.width - nodesBox.x2 + nodeExtent[1][0];
|
||||
|
||||
const y1 = positionAbsolute.y - nodesBox.y + nodeExtent[0][1];
|
||||
const y2 = positionAbsolute.y + (dragItem.measured?.height ?? 0) - nodesBox.y2 + nodeExtent[1][1];
|
||||
const y2 = positionAbsolute.y + dragItem.measured.height - nodesBox.y2 + nodeExtent[1][1];
|
||||
|
||||
adjustedNodeExtent = [
|
||||
[x1, y1],
|
||||
|
||||
@@ -63,8 +63,8 @@ export function getDragItems<NodeType extends NodeBase>(
|
||||
positionAbsolute: internalNode.internals.positionAbsolute || { x: 0, y: 0 },
|
||||
},
|
||||
measured: {
|
||||
width: internalNode.measured.width || 0,
|
||||
height: internalNode.measured.height || 0,
|
||||
width: internalNode.measured.width ?? 0,
|
||||
height: internalNode.measured.height ?? 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user