refactor(core): use useOnInitHandler to emit paneReady event

This commit is contained in:
braks
2024-02-05 07:51:12 +01:00
committed by Braks
parent 9e72e725e8
commit 5798cc5578
6 changed files with 136 additions and 133 deletions
+2 -20
View File
@@ -54,8 +54,6 @@ import { useState } from './state'
export function useActions(
id: string,
emits: any,
hooksOn: any,
state: State,
getters: ComputedGetters,
// todo: change to a Set
@@ -846,7 +844,7 @@ export function useActions(
const y = viewport?.y || position[1]
const nextZoom = viewport?.zoom || zoom || state.viewport.zoom
return until(() => viewportHelper.value.initialized)
return until(() => viewportHelper.value.viewportInitialized)
.toBe(true)
.then(() => {
viewportHelper.value
@@ -891,7 +889,7 @@ export function useActions(
setState(resetState)
}
const actions: Actions = {
return {
updateNodePositions,
updateNodeDimensions,
setElements,
@@ -944,20 +942,4 @@ export function useActions(
$reset,
$destroy: () => {},
}
until(() => viewportHelper.value.initialized)
.toBe(true)
.then(() => {
state.hooks.paneReady.trigger({
id,
emits,
vueFlowVersion: typeof __VUE_FLOW_VERSION__ !== 'undefined' ? __VUE_FLOW_VERSION__ : 'UNKNOWN',
...hooksOn,
...state,
...getters,
...actions,
})
})
return actions
}
+3
View File
@@ -50,6 +50,9 @@ function defaultState(): State {
d3Zoom: null,
d3Selection: null,
d3ZoomHandler: null,
viewportInitialized: false,
minZoom: 0.5,
maxZoom: 2,