chore: Performance optimizations

# What's changed?

* Remove keys
* Stabilize props
* Force reset store on unmount
This commit is contained in:
Braks
2022-04-24 13:34:22 +02:00
parent ad07b5b6ea
commit b6d8b57859
9 changed files with 73 additions and 44 deletions
+8 -2
View File
@@ -55,7 +55,7 @@ const onSelectNodeHandler = (event: MouseEvent) => {
}
onMounted(() => {
useResizeObserver(nodeElement, () =>
const observer = useResizeObserver(nodeElement, () =>
store.updateNodeDimensions([{ id: node.value.id, nodeElement: nodeElement.value, forceUpdate: true }]),
)
@@ -67,6 +67,8 @@ onMounted(() => {
{ flush: 'post' },
)
onBeforeUnmount(() => observer.stop())
store.updateNodeDimensions([{ id: node.value.id, nodeElement: nodeElement.value, forceUpdate: true }])
})
@@ -91,9 +93,13 @@ watch(
node.value.handleBounds = getHandleBounds(nodeElement.value, scale.value)
},
{ deep: true },
)
onUnmounted(() => {
nodeElement.value = undefined
node.value = null
})
store.updateNodePosition({ id: node.value.id, diff: { x: 0, y: 0 } })
const slots = inject(Slots)