refactor(core): use watcheffect to observe node dimensions
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -88,13 +88,16 @@ onUpdateNodeInternals((updateIds) => {
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
props.resizeObserver.observe(nodeElement.value as HTMLDivElement)
|
||||
})
|
||||
watchEffect(
|
||||
(onCleanup) => {
|
||||
if (!node.hidden) {
|
||||
props.resizeObserver.observe(nodeElement.value as HTMLDivElement)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
props.resizeObserver.unobserve(nodeElement.value as HTMLDivElement)
|
||||
})
|
||||
onCleanup(() => props.resizeObserver.unobserve(nodeElement.value as HTMLDivElement))
|
||||
}
|
||||
},
|
||||
{ flush: 'post' },
|
||||
)
|
||||
|
||||
watch(
|
||||
[() => node.type, () => node.sourcePosition, () => node.targetPosition],
|
||||
|
||||
@@ -29,7 +29,7 @@ until(() => nodes.length > 0 && getNodesInitialized.length === nodes.length)
|
||||
|
||||
onMounted(() => {
|
||||
resizeObserver = new ResizeObserver((entries) => {
|
||||
const updates = entries.map((entry: ResizeObserverEntry) => {
|
||||
const updates = entries.map((entry) => {
|
||||
const id = entry.target.getAttribute('data-id') as string
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user