refactor(core): call fitViewOnInit when node dimensions are initially set

This commit is contained in:
braks
2024-02-05 07:51:12 +01:00
committed by Braks
parent 24c2091c7a
commit 0544fbdb6a
3 changed files with 9 additions and 19 deletions
+8
View File
@@ -1,5 +1,6 @@
import { zoomIdentity } from 'd3-zoom'
import type { ComputedRef } from 'vue'
import { nextTick } from 'vue'
import { until } from '@vueuse/core'
import type {
Actions,
@@ -180,6 +181,13 @@ export function useActions(
return res
}, [])
if (!state.fitViewOnInitDone && state.fitViewOnInit) {
nextTick(() => {
viewportHelper.value.fitView()
state.fitViewOnInitDone = true
})
}
if (changes.length) {
state.hooks.nodesChange.trigger(changes)
}