fix: fit view not respecting options nodes
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user