renamed newPosition to nextPosition, removed comment
This commit is contained in:
@@ -12,14 +12,12 @@ import {
|
|||||||
handleExpandParent,
|
handleExpandParent,
|
||||||
evaluateAbsolutePosition,
|
evaluateAbsolutePosition,
|
||||||
ParentExpandChild,
|
ParentExpandChild,
|
||||||
|
XYPosition,
|
||||||
} from '@xyflow/system';
|
} from '@xyflow/system';
|
||||||
|
|
||||||
import { useStoreApi } from '../../hooks/useStore';
|
import { useStoreApi } from '../../hooks/useStore';
|
||||||
import { useNodeId } from '../../contexts/NodeIdContext';
|
import { useNodeId } from '../../contexts/NodeIdContext';
|
||||||
import type { ResizeControlProps, ResizeControlLineProps } from './types';
|
import type { ResizeControlProps, ResizeControlLineProps } from './types';
|
||||||
import { InternalNode, Node } from '../../types';
|
|
||||||
|
|
||||||
type InternalNodeWithParentExpand = InternalNode & { expandParent: true; parentId: string };
|
|
||||||
|
|
||||||
function ResizeControl({
|
function ResizeControl({
|
||||||
nodeId,
|
nodeId,
|
||||||
@@ -71,7 +69,7 @@ function ResizeControl({
|
|||||||
const { triggerNodeChanges, nodeLookup, parentLookup, nodeOrigin } = store.getState();
|
const { triggerNodeChanges, nodeLookup, parentLookup, nodeOrigin } = store.getState();
|
||||||
|
|
||||||
const changes: NodeChange[] = [];
|
const changes: NodeChange[] = [];
|
||||||
const newPosition = { x: change.x, y: change.y };
|
const nextPosition = { x: change.x, y: change.y };
|
||||||
|
|
||||||
const node = nodeLookup.get(id);
|
const node = nodeLookup.get(id);
|
||||||
if (node && node.expandParent && node.parentId) {
|
if (node && node.expandParent && node.parentId) {
|
||||||
@@ -97,15 +95,15 @@ function ResizeControl({
|
|||||||
changes.push(...parentExpandChanges);
|
changes.push(...parentExpandChanges);
|
||||||
|
|
||||||
// when the parent was expanded by the child node, its position will be clamped at 0,0
|
// when the parent was expanded by the child node, its position will be clamped at 0,0
|
||||||
newPosition.x = change.x ? Math.max(0, change.x) : undefined;
|
nextPosition.x = change.x ? Math.max(0, change.x) : undefined;
|
||||||
newPosition.y = change.y ? Math.max(0, change.y) : undefined;
|
nextPosition.y = change.y ? Math.max(0, change.y) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change.x !== undefined && change.y !== undefined) {
|
if (nextPosition.x !== undefined && nextPosition.y !== undefined) {
|
||||||
const positionChange: NodePositionChange = {
|
const positionChange: NodePositionChange = {
|
||||||
id,
|
id,
|
||||||
type: 'position',
|
type: 'position',
|
||||||
position: { ...newPosition } as { x: number; y: number },
|
position: { ...(nextPosition as XYPosition) },
|
||||||
};
|
};
|
||||||
changes.push(positionChange);
|
changes.push(positionChange);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ export function adoptUserNodes<NodeType extends NodeBase>(
|
|||||||
parentLookup.clear();
|
parentLookup.clear();
|
||||||
|
|
||||||
const selectedNodeZ: number = options?.elevateNodesOnSelect ? 1000 : 0;
|
const selectedNodeZ: number = options?.elevateNodesOnSelect ? 1000 : 0;
|
||||||
// const parentNodeIds = new Set<string>();
|
|
||||||
|
|
||||||
nodes.forEach((userNode) => {
|
nodes.forEach((userNode) => {
|
||||||
const currentStoreNode = tmpLookup.get(userNode.id);
|
const currentStoreNode = tmpLookup.get(userNode.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user