clamp global nodeExtent correctly
This commit is contained in:
@@ -151,7 +151,7 @@ function updateChildNode<NodeType extends NodeBase>(
|
|||||||
parentLookup: ParentLookup<InternalNodeBase<NodeType>>,
|
parentLookup: ParentLookup<InternalNodeBase<NodeType>>,
|
||||||
options?: UpdateNodesOptions<NodeType>
|
options?: UpdateNodesOptions<NodeType>
|
||||||
) {
|
) {
|
||||||
const { elevateNodesOnSelect, nodeOrigin } = mergeObjects(defaultOptions, options);
|
const { elevateNodesOnSelect, nodeOrigin, nodeExtent } = mergeObjects(defaultOptions, options);
|
||||||
const parentId = node.parentId!;
|
const parentId = node.parentId!;
|
||||||
const parentNode = nodeLookup.get(parentId);
|
const parentNode = nodeLookup.get(parentId);
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ function updateChildNode<NodeType extends NodeBase>(
|
|||||||
updateParentLookup(node, parentLookup);
|
updateParentLookup(node, parentLookup);
|
||||||
|
|
||||||
const selectedNodeZ = elevateNodesOnSelect ? 1000 : 0;
|
const selectedNodeZ = elevateNodesOnSelect ? 1000 : 0;
|
||||||
const { x, y, z } = calculateChildXYZ(node, parentNode, nodeOrigin, selectedNodeZ);
|
const { x, y, z } = calculateChildXYZ(node, parentNode, nodeOrigin, nodeExtent, selectedNodeZ);
|
||||||
const { positionAbsolute } = node.internals;
|
const { positionAbsolute } = node.internals;
|
||||||
const positionChanged = x !== positionAbsolute.x || y !== positionAbsolute.y;
|
const positionChanged = x !== positionAbsolute.x || y !== positionAbsolute.y;
|
||||||
|
|
||||||
@@ -186,6 +186,7 @@ function calculateChildXYZ<NodeType extends NodeBase>(
|
|||||||
childNode: InternalNodeBase<NodeType>,
|
childNode: InternalNodeBase<NodeType>,
|
||||||
parentNode: InternalNodeBase<NodeType>,
|
parentNode: InternalNodeBase<NodeType>,
|
||||||
nodeOrigin: NodeOrigin,
|
nodeOrigin: NodeOrigin,
|
||||||
|
nodeExtent: CoordinateExtent,
|
||||||
selectedNodeZ: number
|
selectedNodeZ: number
|
||||||
) {
|
) {
|
||||||
const { x: parentX, y: parentY } = parentNode.internals.positionAbsolute;
|
const { x: parentX, y: parentY } = parentNode.internals.positionAbsolute;
|
||||||
@@ -195,7 +196,11 @@ function calculateChildXYZ<NodeType extends NodeBase>(
|
|||||||
? clampPosition(positionWithOrigin, childNode.extent, childDimensions)
|
? clampPosition(positionWithOrigin, childNode.extent, childDimensions)
|
||||||
: positionWithOrigin;
|
: positionWithOrigin;
|
||||||
|
|
||||||
let absolutePosition = { x: parentX + clampedPosition.x, y: parentY + clampedPosition.y };
|
let absolutePosition = clampPosition(
|
||||||
|
{ x: parentX + clampedPosition.x, y: parentY + clampedPosition.y },
|
||||||
|
nodeExtent,
|
||||||
|
childDimensions
|
||||||
|
);
|
||||||
|
|
||||||
if (childNode.extent === 'parent') {
|
if (childNode.extent === 'parent') {
|
||||||
absolutePosition = clampPositionToParent(absolutePosition, childDimensions, parentNode);
|
absolutePosition = clampPositionToParent(absolutePosition, childDimensions, parentNode);
|
||||||
|
|||||||
Reference in New Issue
Block a user