refactor(nodes): set resize observer before mount

This commit is contained in:
bcakmakoglu
2022-06-07 18:33:00 +02:00
committed by Braks
parent 7dd79f6256
commit 87f97efd42
@@ -54,23 +54,21 @@ const dragging = useDrag({
}, },
}) })
onMounted(() => { const observer = useResizeObserver(nodeElement, () => {
const observer = useResizeObserver(nodeElement, () =>
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]),
)
watch(
[() => node.type, () => node.sourcePosition, () => node.targetPosition],
() => {
updateNodeDimensions([{ id, nodeElement: nodeElement.value }])
},
{ flush: 'post' },
)
onBeforeUnmount(() => observer.stop())
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])
})
watch(
[() => node.width, () => node.height, () => node.type, () => node.sourcePosition, () => node.targetPosition],
() => {
updateNodeDimensions([{ id, nodeElement: nodeElement.value }])
},
{ flush: 'post' },
)
onBeforeUnmount(() => observer.stop())
onMounted(() => {
watch( watch(
[ [
() => node.position.x, () => node.position.x,