refactor(core): fit view initially when node dimensions are updated

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-02-10 16:00:17 +01:00
committed by Braks
parent a5ee9d978c
commit 3f21dc764d
+9
View File
@@ -21,6 +21,8 @@ import type {
} from '~/types'
export function useActions(state: State, getters: ComputedGetters): Actions {
let fitViewOnInitDone = false
const updateNodeInternals: Actions['updateNodeInternals'] = (ids) => {
state.hooks.updateNodeInternals.trigger(ids)
}
@@ -151,6 +153,13 @@ export function useActions(state: State, getters: ComputedGetters): Actions {
return res
}, [])
if (state.fitViewOnInit && !fitViewOnInitDone) {
paneReady().then((helper) => {
helper.fitView()
fitViewOnInitDone = true
})
}
if (changes.length) state.hooks.nodesChange.trigger(changes)
}