Merge branch 'next' into enhance-connection-more

This commit is contained in:
moklick
2024-06-27 17:14:17 +02:00
42 changed files with 383 additions and 370 deletions
+7 -4
View File
@@ -7,6 +7,7 @@ import {
updateConnectionLookup,
devWarn,
getInternalNodesBounds,
NodeOrigin,
initialConnection,
} from '@xyflow/system';
@@ -20,6 +21,7 @@ const getInitialState = ({
width,
height,
fitView,
nodeOrigin,
}: {
nodes?: Node[];
edges?: Edge[];
@@ -28,6 +30,7 @@ const getInitialState = ({
width?: number;
height?: number;
fitView?: boolean;
nodeOrigin?: NodeOrigin;
} = {}): ReactFlowStore => {
const nodeLookup = new Map<string, InternalNode>();
const parentLookup = new Map();
@@ -35,21 +38,21 @@ const getInitialState = ({
const edgeLookup = new Map();
const storeEdges = defaultEdges ?? edges ?? [];
const storeNodes = defaultNodes ?? nodes ?? [];
const storeNodeOrigin = nodeOrigin ?? [0, 0];
updateConnectionLookup(connectionLookup, edgeLookup, storeEdges);
adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
nodeOrigin: [0, 0],
nodeOrigin: storeNodeOrigin,
elevateNodesOnSelect: false,
});
let transform: Transform = [0, 0, 1];
if (fitView && width && height) {
// @todo users nodeOrigin should be used here
const bounds = getInternalNodesBounds(nodeLookup, {
nodeOrigin: [0, 0],
filter: (node) => !!((node.width || node.initialWidth) && (node.height || node.initialHeight)),
});
const { x, y, zoom } = getViewportForBounds(bounds, width, height, 0.5, 2, 0.1);
transform = [x, y, zoom];
}
@@ -81,7 +84,7 @@ const getInitialState = ({
domNode: null,
paneDragging: false,
noPanClassName: 'nopan',
nodeOrigin: [0, 0],
nodeOrigin: storeNodeOrigin,
nodeDragThreshold: 1,
snapGrid: [15, 15],