fix(core): abort fit view when there's no nodes to fit around

This commit is contained in:
braks
2023-07-22 08:46:32 +02:00
committed by Braks
parent 1ac6591d23
commit 6bd442f844

View File

@@ -85,10 +85,6 @@ export function useViewport(state: State, getters: ComputedGetters) {
duration: 0,
},
) => {
if (!nodes.length) {
return
}
const nodesToFit: GraphNode[] = (options.includeHiddenNodes ? nodes : getNodes.value).filter((node) => {
const initialized = node.initialized && node.dimensions.width && node.dimensions.height
let shouldInclude = true
@@ -100,6 +96,10 @@ export function useViewport(state: State, getters: ComputedGetters) {
return initialized && shouldInclude
})
if (!nodesToFit.length) {
return
}
const bounds = getRectOfNodes(nodesToFit)
const { x, y, zoom } = getTransformForBounds(