Skip to content

Commit 12c9e4e

Browse files
committed
chore(core,nodes): remove mounted hook for initial clamp
Signed-off-by: braks <[email protected]>
1 parent 18aba90 commit 12c9e4e

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

packages/core/src/components/Nodes/NodeWrapper.vue

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
22
import { isNumber } from '@vueuse/core'
3+
import type { ReactiveVariable } from 'vue/macros'
34
import type { GraphNode, HandleConnectable, NodeComponent, SnapGrid, XYZPosition } from '../../types'
45
import { ARIA_NODE_DESC_KEY } from '../../utils/a11y'
56
@@ -42,16 +43,14 @@ const {
4243
4344
const updateNodePositions = useUpdateNodePositions()
4445
45-
const node = $(useVModel(props, 'node'))
46+
const node: ReactiveVariable<GraphNode> = $(useVModel(props, 'node'))
4647
4748
const parentNode = $computed(() => (node.parentNode ? getNode(node.parentNode) : undefined))
4849
4950
const connectedEdges = $computed(() => getConnectedEdges([node], edges))
5051
5152
const nodeElement = ref()
5253
53-
const initialized = ref(false)
54-
5554
provide(NodeRef, nodeElement)
5655
5756
const { emit, on } = useNodeHooks(node, emits)
@@ -129,7 +128,7 @@ watch(
129128
130129
updatePosition(xyzPos, parentX && parentY ? { x: parentX, y: parentY, z: parentZ || 0 } : undefined)
131130
},
132-
{ flush: 'post', immediate: true },
131+
{ flush: 'pre', immediate: true },
133132
)
134133
135134
function updatePosition(nodePos: XYZPosition, parentPos?: XYZPosition) {
@@ -142,19 +141,13 @@ function updatePosition(nodePos: XYZPosition, parentPos?: XYZPosition) {
142141
node.computedPosition = nextPos
143142
}
144143
145-
onNodesInitialized(() => {
146-
initialized.value = true
147-
})
148-
149-
onMounted(() => {
150-
until(initialized)
151-
.toBe(true)
152-
.then(() => {
153-
const { position } = calcNextPosition(node, node.computedPosition, nodeExtent, parentNode)
144+
until(() => node.initialized)
145+
.toBe(true)
146+
.then(() => {
147+
const { position } = calcNextPosition(node, node.computedPosition, nodeExtent, parentNode)
154148
155-
node.computedPosition = { ...node.computedPosition, ...position }
156-
})
157-
})
149+
node.computedPosition = { ...node.computedPosition, ...position }
150+
})
158151
159152
function updateInternals() {
160153
if (nodeElement.value) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])

0 commit comments

Comments
 (0)