refactor(nodes): recreate scope on mount
This commit is contained in:
@@ -38,7 +38,7 @@ const nodeElement = ref()
|
|||||||
|
|
||||||
const { emit, on } = useNodeHooks(node, emits)
|
const { emit, on } = useNodeHooks(node, emits)
|
||||||
|
|
||||||
const scope = effectScope()
|
let scope: ReturnType<typeof effectScope> | undefined = effectScope()
|
||||||
|
|
||||||
const dragging = useDrag({
|
const dragging = useDrag({
|
||||||
id,
|
id,
|
||||||
@@ -91,11 +91,13 @@ onUpdateNodeInternals((updateIds) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (!scope) scope = effectScope()
|
||||||
|
|
||||||
scope.run(() => {
|
scope.run(() => {
|
||||||
watch(
|
watch(
|
||||||
[() => node.width, () => node.height, () => 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, forceUpdate: true }])
|
||||||
},
|
},
|
||||||
{ flush: 'post', immediate: true },
|
{ flush: 'post', immediate: true },
|
||||||
)
|
)
|
||||||
@@ -132,7 +134,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
observer.stop()
|
observer.stop()
|
||||||
scope.stop()
|
scope?.stop()
|
||||||
|
scope = undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
const onMouseEnter = (event: MouseEvent) => {
|
const onMouseEnter = (event: MouseEvent) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user