fix: fit view not respecting options nodes

This commit is contained in:
Braks
2022-05-11 22:10:40 +02:00
parent b68dc4c032
commit 5fb0280e5b
+6 -5
View File
@@ -31,6 +31,7 @@ const untilDimensions = async (dimensions: Dimensions, getNodes: Getters['getNod
export default (): ViewportFuncs => { export default (): ViewportFuncs => {
const { const {
onPaneReady, onPaneReady,
nodes,
d3Zoom, d3Zoom,
d3Selection, d3Selection,
dimensions, dimensions,
@@ -106,16 +107,16 @@ export default (): ViewportFuncs => {
if (!getNodes.length) return if (!getNodes.length) return
let nodes: GraphNode[] = [] let nodeBounds: GraphNode[] = []
if (options.nodes) { if (options.nodes) {
nodes = nodes.filter((n) => options.nodes?.includes(n.id)) nodeBounds = nodes.filter((n) => options.nodes?.includes(n.id))
} }
if (!nodes || !nodes.length) { if (!nodeBounds || !nodeBounds.length) {
nodes = options.includeHiddenNodes ? nodes : getNodes nodeBounds = options.includeHiddenNodes ? nodeBounds : getNodes
} }
const bounds = getRectOfNodes(nodes) const bounds = getRectOfNodes(nodeBounds)
const { x, y, zoom } = getTransformForBounds( const { x, y, zoom } = getTransformForBounds(
bounds, bounds,