fix: onLoad being triggered when elements aren't ready
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -126,28 +126,26 @@ const init = (state: FlowState) => {
|
|||||||
}
|
}
|
||||||
onBeforeUnmount(() => store?.$dispose())
|
onBeforeUnmount(() => store?.$dispose())
|
||||||
|
|
||||||
onMounted(() => {
|
init(options)
|
||||||
init(options)
|
watch(elements, (val) => store.setElements(val), { flush: 'post', deep: true })
|
||||||
watch(elements, (val) => store.setElements(val), { flush: 'post', deep: true })
|
watch(
|
||||||
watch(
|
() => store.elements,
|
||||||
() => store.elements,
|
(val, oldVal) => {
|
||||||
(val, oldVal) => {
|
nextTick(() => {
|
||||||
nextTick(() => {
|
|
||||||
const hasDiff = diff(val, oldVal)
|
|
||||||
if (hasDiff.length > 0) elements.value = val
|
|
||||||
})
|
|
||||||
},
|
|
||||||
{ flush: 'post', deep: true },
|
|
||||||
)
|
|
||||||
watch(
|
|
||||||
() => props,
|
|
||||||
(val, oldVal) => {
|
|
||||||
const hasDiff = diff(val, oldVal)
|
const hasDiff = diff(val, oldVal)
|
||||||
if (hasDiff.length > 0) init({ ...store.$state, ...val } as FlowState)
|
if (hasDiff.length > 0) elements.value = val
|
||||||
},
|
})
|
||||||
{ flush: 'pre', deep: true },
|
},
|
||||||
)
|
{ flush: 'post', deep: true },
|
||||||
})
|
)
|
||||||
|
watch(
|
||||||
|
() => props,
|
||||||
|
(val, oldVal) => {
|
||||||
|
const hasDiff = diff(val, oldVal)
|
||||||
|
if (hasDiff.length > 0) init({ ...store.$state, ...val } as FlowState)
|
||||||
|
},
|
||||||
|
{ flush: 'pre', deep: true },
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="vue-flow">
|
<div class="vue-flow">
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ store.dimensions = {
|
|||||||
|
|
||||||
invoke(async () => {
|
invoke(async () => {
|
||||||
await until(() => !isNaN(width.value) && width.value > 0 && !isNaN(height.value) && height.value > 0).toBeTruthy()
|
await until(() => !isNaN(width.value) && width.value > 0 && !isNaN(height.value) && height.value > 0).toBeTruthy()
|
||||||
|
await until(store.elements).toMatch((y) => y.length > 0)
|
||||||
const instance: FlowInstance = {
|
const instance: FlowInstance = {
|
||||||
fitView: (params = { padding: 0.1 }) => fitView(params),
|
fitView: (params = { padding: 0.1 }) => fitView(params),
|
||||||
zoomIn,
|
zoomIn,
|
||||||
|
|||||||
Reference in New Issue
Block a user