fix(core): abort fit view when there's no nodes to fit around
This commit is contained in:
@@ -85,10 +85,6 @@ export function useViewport(state: State, getters: ComputedGetters) {
|
|||||||
duration: 0,
|
duration: 0,
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
if (!nodes.length) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const nodesToFit: GraphNode[] = (options.includeHiddenNodes ? nodes : getNodes.value).filter((node) => {
|
const nodesToFit: GraphNode[] = (options.includeHiddenNodes ? nodes : getNodes.value).filter((node) => {
|
||||||
const initialized = node.initialized && node.dimensions.width && node.dimensions.height
|
const initialized = node.initialized && node.dimensions.width && node.dimensions.height
|
||||||
let shouldInclude = true
|
let shouldInclude = true
|
||||||
@@ -100,6 +96,10 @@ export function useViewport(state: State, getters: ComputedGetters) {
|
|||||||
return initialized && shouldInclude
|
return initialized && shouldInclude
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!nodesToFit.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const bounds = getRectOfNodes(nodesToFit)
|
const bounds = getRectOfNodes(nodesToFit)
|
||||||
|
|
||||||
const { x, y, zoom } = getTransformForBounds(
|
const { x, y, zoom } = getTransformForBounds(
|
||||||
|
|||||||
Reference in New Issue
Block a user