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,13 +54,12 @@ const dragging = useDrag({
}, },
}) })
onMounted(() => { const observer = useResizeObserver(nodeElement, () => {
const observer = useResizeObserver(nodeElement, () => updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]), })
)
watch( watch(
[() => node.type, () => node.sourcePosition, () => node.targetPosition], [() => node.width, () => node.height, () => node.type, () => node.sourcePosition, () => node.targetPosition],
() => { () => {
updateNodeDimensions([{ id, nodeElement: nodeElement.value }]) updateNodeDimensions([{ id, nodeElement: nodeElement.value }])
}, },
@@ -69,8 +68,7 @@ onMounted(() => {
onBeforeUnmount(() => observer.stop()) onBeforeUnmount(() => observer.stop())
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]) onMounted(() => {
watch( watch(
[ [
() => node.position.x, () => node.position.x,