11<script lang="ts" setup>
22import { isNumber } from ' @vueuse/core'
3+ import type { ReactiveVariable } from ' vue/macros'
34import type { GraphNode , HandleConnectable , NodeComponent , SnapGrid , XYZPosition } from ' ../../types'
45import { ARIA_NODE_DESC_KEY } from ' ../../utils/a11y'
56
@@ -42,16 +43,14 @@ const {
4243
4344const updateNodePositions = useUpdateNodePositions ()
4445
45- const node = $ (useVModel (props , ' node' ))
46+ const node: ReactiveVariable < GraphNode > = $ (useVModel (props , ' node' ))
4647
4748const parentNode = $computed (() => (node .parentNode ? getNode (node .parentNode ) : undefined ))
4849
4950const connectedEdges = $computed (() => getConnectedEdges ([node ], edges ))
5051
5152const nodeElement = ref ()
5253
53- const initialized = ref (false )
54-
5554provide (NodeRef , nodeElement )
5655
5756const { 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
135134function 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
159152function updateInternals() {
160153 if (nodeElement .value ) updateNodeDimensions ([{ id , nodeElement: nodeElement .value , forceUpdate: true }])
0 commit comments