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) 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) until(() => viewportHelper.value.initialized)
.toBe(true) .toBe(true)
.then(() => { .then(() => {
viewportHelper.value.setViewport({ viewportHelper.value.setViewport({
x: viewport.x || position[0], x,
y: viewport.y || position[1], y,
zoom: viewport.zoom || zoom || state.viewport.zoom, zoom: nextZoom,
}) })
}) })
} }