chore(system/extends): cleanup
This commit is contained in:
@@ -289,10 +289,6 @@ const createStore = ({
|
|||||||
setNodeExtent: (nodeExtent) => {
|
setNodeExtent: (nodeExtent) => {
|
||||||
const { nodes, nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect } = get();
|
const { nodes, nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect } = get();
|
||||||
|
|
||||||
set({
|
|
||||||
nodeExtent,
|
|
||||||
});
|
|
||||||
|
|
||||||
adoptUserNodes(nodes, nodeLookup, parentLookup, {
|
adoptUserNodes(nodes, nodeLookup, parentLookup, {
|
||||||
nodeOrigin,
|
nodeOrigin,
|
||||||
nodeExtent,
|
nodeExtent,
|
||||||
@@ -300,7 +296,7 @@ const createStore = ({
|
|||||||
checkEquality: false,
|
checkEquality: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
set({ nodes });
|
set({ nodeExtent });
|
||||||
},
|
},
|
||||||
panBy: (delta): Promise<boolean> => {
|
panBy: (delta): Promise<boolean> => {
|
||||||
const { transform, width, height, panZoom, translateExtent } = get();
|
const { transform, width, height, panZoom, translateExtent } = get();
|
||||||
|
|||||||
@@ -193,16 +193,14 @@ function calculateChildXYZ<NodeType extends NodeBase>(
|
|||||||
nodeOrigin: NodeOrigin,
|
nodeOrigin: NodeOrigin,
|
||||||
selectedNodeZ: number
|
selectedNodeZ: number
|
||||||
) {
|
) {
|
||||||
const childDimensions = getNodeDimensions(childNode);
|
|
||||||
const parentPosition = parentNode.internals.positionAbsolute;
|
const parentPosition = parentNode.internals.positionAbsolute;
|
||||||
|
const childDimensions = getNodeDimensions(childNode);
|
||||||
|
const positionWithOrigin = getNodePositionWithOrigin(childNode, nodeOrigin);
|
||||||
|
const clampedPosition = isCoordinateExtent(childNode.extent)
|
||||||
|
? clampPosition(positionWithOrigin, childNode.extent, childDimensions)
|
||||||
|
: positionWithOrigin;
|
||||||
|
|
||||||
let position = getNodePositionWithOrigin(childNode, nodeOrigin);
|
let absolutePosition = { x: parentPosition.x + clampedPosition.x, y: parentPosition.y + clampedPosition.y };
|
||||||
|
|
||||||
if (isCoordinateExtent(childNode.extent)) {
|
|
||||||
position = clampPosition(position, childNode.extent, childDimensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
let absolutePosition = { x: parentPosition.x + position.x, y: parentPosition.y + position.y };
|
|
||||||
|
|
||||||
if (childNode.extent === 'parent') {
|
if (childNode.extent === 'parent') {
|
||||||
absolutePosition = clampPositionToParent(absolutePosition, childDimensions, parentNode);
|
absolutePosition = clampPositionToParent(absolutePosition, childDimensions, parentNode);
|
||||||
@@ -348,14 +346,11 @@ export function updateNodeInternals<NodeType extends InternalNodeBase>(
|
|||||||
|
|
||||||
if (doUpdate) {
|
if (doUpdate) {
|
||||||
const nodeBounds = update.nodeElement.getBoundingClientRect();
|
const nodeBounds = update.nodeElement.getBoundingClientRect();
|
||||||
let extent = isCoordinateExtent(node.extent) ? node.extent : nodeExtent;
|
const extent = isCoordinateExtent(node.extent) ? node.extent : nodeExtent;
|
||||||
let positionAbsolute = node.internals.positionAbsolute;
|
let { positionAbsolute } = node.internals;
|
||||||
|
|
||||||
if (node.parentId && node.extent === 'parent') {
|
if (node.parentId && node.extent === 'parent') {
|
||||||
positionAbsolute = clampPositionToParent(
|
positionAbsolute = clampPositionToParent(positionAbsolute, dimensions, nodeLookup.get(node.parentId)!);
|
||||||
positionAbsolute,
|
|
||||||
getNodeDimensions(node),
|
|
||||||
nodeLookup.get(node.parentId)!
|
|
||||||
);
|
|
||||||
} else if (extent) {
|
} else if (extent) {
|
||||||
positionAbsolute = clampPosition(positionAbsolute, extent, dimensions);
|
positionAbsolute = clampPosition(positionAbsolute, extent, dimensions);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user