update(nodes): watch nodes width for dimension update

* add force param to setElements, if set we clear the elements arr (default true)
* wait for store watcher until store is ready (i.e. a state has been set)
* move renderer css class to Renderer.vue

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-25 19:29:13 +01:00
parent 5b00049a65
commit 0b2764028f
9 changed files with 46 additions and 32 deletions
+18 -15
View File
@@ -116,19 +116,22 @@ const { pause: pauseModel, resume: resumeModel } = pausableWatch(
async () => await store.setElements(elements.value),
)
const { pause, resume } = pausableWatch(elements, async (val) => await store.setElements(val), { flush: 'post' })
watch(
() => store.elements,
(val) => {
pause()
pauseModel()
elements.value = val
setTimeout(() => {
resume()
resumeModel()
}, 1)
},
{ flush: 'post', deep: true },
)
until(() => store.isReady).toBe(true).then(() => {
watch(
() => store.elements,
(val) => {
pause()
pauseModel()
elements.value = val
setTimeout(() => {
resume()
resumeModel()
}, 1)
},
{ flush: 'post', deep: true },
)
})
const transitionName = computed(() => {
let name = ''
@@ -149,9 +152,9 @@ export default {
<template>
<div class="vue-flow">
<Transition :key="`vue-flow-transition-${store.$id}`" :name="transitionName">
<Suspense>
<Suspense timeout="0">
<template #default>
<Renderer :elements="elements">
<Renderer :key="`renderer-${store.$id}`" :elements="elements">
<ZoomPane
:key="`zoom-pane-${store.$id}`"
:prevent-scrolling="store.preventScrolling"