refactor(core): emit pane ready after timeout of 1ms

This commit is contained in:
braks
2024-01-29 21:56:44 +01:00
committed by Braks
parent 308cff5f45
commit abe6006a09
+17 -13
View File
@@ -209,6 +209,12 @@ export function useActions(
return res return res
}, []) }, [])
if (!state.fitViewOnInitDone && state.fitViewOnInit) {
viewportHelper.value.fitView()
}
state.fitViewOnInitDone = true
if (changes.length) { if (changes.length) {
state.hooks.nodesChange.trigger(changes) state.hooks.nodesChange.trigger(changes)
} }
@@ -964,19 +970,17 @@ export function useActions(
until(() => viewportHelper.value.initialized) until(() => viewportHelper.value.initialized)
.toBe(true) .toBe(true)
.then(async () => { .then(async () => {
if (state.fitViewOnInit) { setTimeout(() => {
await viewportHelper.value.fitView() state.hooks.paneReady.trigger({
} id,
emits,
state.hooks.paneReady.trigger({ vueFlowVersion: typeof __VUE_FLOW_VERSION__ !== 'undefined' ? __VUE_FLOW_VERSION__ : 'UNKNOWN',
id, ...hooksOn,
emits, ...state,
vueFlowVersion: typeof __VUE_FLOW_VERSION__ !== 'undefined' ? __VUE_FLOW_VERSION__ : 'UNKNOWN', ...getters,
...hooksOn, ...actions,
...state, })
...getters, }, 1)
...actions,
})
}) })
return actions return actions