fix(nodeOrigin): repair multi selection and fitView

This commit is contained in:
moklick
2022-11-15 16:00:21 +01:00
parent fd00b18ebe
commit b70ede04f3
6 changed files with 74 additions and 40 deletions
@@ -8,6 +8,7 @@ import ReactFlow, {
Node,
Edge,
useReactFlow,
NodeOrigin,
} from 'reactflow';
const onNodeDrag = (_: MouseEvent, node: Node) => console.log('drag', node);
@@ -47,6 +48,8 @@ const initialEdges: Edge[] = [
{ id: 'e1-3', source: '1', target: '3' },
];
const nodeOrigin: NodeOrigin = [0.5, 0.5];
const defaultEdgeOptions = { zIndex: 0 };
const BasicFlow = () => {
@@ -91,6 +94,7 @@ const BasicFlow = () => {
fitView
defaultEdgeOptions={defaultEdgeOptions}
selectNodesOnDrag={false}
nodeOrigin={nodeOrigin}
>
<Background variant={BackgroundVariant.Dots} />
<MiniMap />
@@ -106,7 +110,9 @@ const BasicFlow = () => {
<button onClick={toggleClassnames} style={{ marginRight: 5 }}>
toggle classnames
</button>
<button onClick={logToObject} style={{ marginRight: 5 }}>toObject</button>
<button onClick={logToObject} style={{ marginRight: 5 }}>
toObject
</button>
</div>
</ReactFlow>
);