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(() => {
|
watchEffect(
|
||||||
props.resizeObserver.observe(nodeElement.value as HTMLDivElement)
|
(onCleanup) => {
|
||||||
})
|
if (!node.hidden) {
|
||||||
|
props.resizeObserver.observe(nodeElement.value as HTMLDivElement)
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onCleanup(() => props.resizeObserver.unobserve(nodeElement.value as HTMLDivElement))
|
||||||
props.resizeObserver.unobserve(nodeElement.value as HTMLDivElement)
|
}
|
||||||
})
|
},
|
||||||
|
{ flush: 'post' },
|
||||||
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => node.type, () => node.sourcePosition, () => node.targetPosition],
|
[() => node.type, () => node.sourcePosition, () => node.targetPosition],
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ until(() => nodes.length > 0 && getNodesInitialized.length === nodes.length)
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
resizeObserver = new ResizeObserver((entries) => {
|
resizeObserver = new ResizeObserver((entries) => {
|
||||||
const updates = entries.map((entry: ResizeObserverEntry) => {
|
const updates = entries.map((entry) => {
|
||||||
const id = entry.target.getAttribute('data-id') as string
|
const id = entry.target.getAttribute('data-id') as string
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user