Merge pull request #4477 from xyflow/nodesbounds
Added getNodesBounds function to useReactFlow/useSvelteFlow
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
EdgeRemoveChange,
|
||||
evaluateAbsolutePosition,
|
||||
getElementsToRemove,
|
||||
getNodesBounds,
|
||||
getOverlappingArea,
|
||||
isRectObject,
|
||||
NodeRemoveChange,
|
||||
@@ -230,6 +231,10 @@ export function useReactFlow<NodeType extends Node = Node, EdgeType extends Edge
|
||||
options
|
||||
);
|
||||
},
|
||||
getNodesBounds: (nodes: (NodeType | InternalNode | string)[]): Rect => {
|
||||
const { nodeLookup, nodeOrigin } = store.getState();
|
||||
return getNodesBounds(nodes, { nodeLookup, nodeOrigin });
|
||||
},
|
||||
getHandleConnections: ({ type, id, nodeId }) =>
|
||||
Array.from(
|
||||
store
|
||||
|
||||
@@ -173,6 +173,14 @@ export type GeneralHelpers<NodeType extends Node = Node, EdgeType extends Edge =
|
||||
dataUpdate: Partial<EdgeType['data']> | ((edge: EdgeType) => Partial<EdgeType['data']>),
|
||||
options?: { replace: boolean }
|
||||
) => void;
|
||||
/**
|
||||
* Returns the bounds of the given nodes or node ids.
|
||||
*
|
||||
* @param nodes - the nodes or node ids to calculate the bounds for
|
||||
*
|
||||
* @returns the bounds of the given nodes
|
||||
*/
|
||||
getNodesBounds: (nodes: (NodeType | InternalNode | string)[]) => Rect;
|
||||
/**
|
||||
* Gets all connections for a given handle belonging to a specific node.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user