fix(core): use noop viewport operations instead of waiting for promise

This commit is contained in:
braks
2023-07-19 19:12:29 +02:00
committed by Braks
parent 715206404b
commit 4d5bbab506
4 changed files with 46 additions and 92 deletions
+1 -8
View File
@@ -36,14 +36,7 @@ export function useViewport(state: State, getters: ComputedGetters) {
nodesInitialized.value = true
})
const isReady = computed(
() =>
!!d3Zoom &&
!!d3Selection &&
!!dimensions.width &&
!!dimensions.height &&
(getNodes.value.length ? nodesInitialized.value : true),
)
const isReady = computed(() => !!d3Zoom && !!d3Selection && !!dimensions.width && !!dimensions.height && nodesInitialized.value)
function zoom(scale: number, duration?: number) {
if (d3Selection && d3Zoom) {
+7 -7
View File
@@ -39,13 +39,6 @@ export class Storage {
const reactiveState = reactive(state)
const nodeIds = computed(() => reactiveState.nodes.map((n) => n.id))
const edgeIds = computed(() => reactiveState.edges.map((e) => e.id))
const getters = useGetters(reactiveState, nodeIds, edgeIds)
const actions = useActions(reactiveState, getters, nodeIds, edgeIds)
const hooksOn = <any>{}
Object.entries(reactiveState.hooks).forEach(([n, h]) => {
const name = `on${n.charAt(0).toUpperCase() + n.slice(1)}`
@@ -57,6 +50,13 @@ export class Storage {
emits[n] = h.trigger
})
const nodeIds = computed(() => reactiveState.nodes.map((n) => n.id))
const edgeIds = computed(() => reactiveState.edges.map((e) => e.id))
const getters = useGetters(reactiveState, nodeIds, edgeIds)
const actions = useActions(id, emits, hooksOn, reactiveState, getters, nodeIds, edgeIds)
actions.setState(reactiveState)
const flow: VueFlowStore = {