fix(core): check if viewport is defined before setting

This commit is contained in:
braks
2023-07-27 18:36:41 +02:00
committed by Braks
parent cfbc4d2065
commit 9d1f5fa629
+8 -4
View File
@@ -844,14 +844,18 @@ export function useActions(
setEdges(edges)
}
if (viewport || position) {
if ((viewport?.x && viewport?.y) || position) {
const x = viewport?.x || position[0]
const y = viewport?.y || position[1]
const nextZoom = viewport?.zoom || zoom || state.viewport.zoom
until(() => viewportHelper.value.initialized)
.toBe(true)
.then(() => {
viewportHelper.value.setViewport({
x: viewport.x || position[0],
y: viewport.y || position[1],
zoom: viewport.zoom || zoom || state.viewport.zoom,
x,
y,
zoom: nextZoom,
})
})
}