chore(core,nodes): remove mounted hook for initial clamp

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-20 00:38:56 +01:00
committed by Braks
parent 18aba904c8
commit 12c9e4e07b
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { isNumber } from '@vueuse/core' import { isNumber } from '@vueuse/core'
import type { ReactiveVariable } from 'vue/macros'
import type { GraphNode, HandleConnectable, NodeComponent, SnapGrid, XYZPosition } from '../../types' import type { GraphNode, HandleConnectable, NodeComponent, SnapGrid, XYZPosition } from '../../types'
import { ARIA_NODE_DESC_KEY } from '../../utils/a11y' import { ARIA_NODE_DESC_KEY } from '../../utils/a11y'
@@ -42,7 +43,7 @@ const {
const updateNodePositions = useUpdateNodePositions() const updateNodePositions = useUpdateNodePositions()
const node = $(useVModel(props, 'node')) const node: ReactiveVariable<GraphNode> = $(useVModel(props, 'node'))
const parentNode = $computed(() => (node.parentNode ? getNode(node.parentNode) : undefined)) const parentNode = $computed(() => (node.parentNode ? getNode(node.parentNode) : undefined))
@@ -50,8 +51,6 @@ const connectedEdges = $computed(() => getConnectedEdges([node], edges))
const nodeElement = ref() const nodeElement = ref()
const initialized = ref(false)
provide(NodeRef, nodeElement) provide(NodeRef, nodeElement)
const { emit, on } = useNodeHooks(node, emits) const { emit, on } = useNodeHooks(node, emits)
@@ -129,7 +128,7 @@ watch(
updatePosition(xyzPos, parentX && parentY ? { x: parentX, y: parentY, z: parentZ || 0 } : undefined) updatePosition(xyzPos, parentX && parentY ? { x: parentX, y: parentY, z: parentZ || 0 } : undefined)
}, },
{ flush: 'post', immediate: true }, { flush: 'pre', immediate: true },
) )
function updatePosition(nodePos: XYZPosition, parentPos?: XYZPosition) { function updatePosition(nodePos: XYZPosition, parentPos?: XYZPosition) {
@@ -142,19 +141,13 @@ function updatePosition(nodePos: XYZPosition, parentPos?: XYZPosition) {
node.computedPosition = nextPos node.computedPosition = nextPos
} }
onNodesInitialized(() => { until(() => node.initialized)
initialized.value = true .toBe(true)
}) .then(() => {
const { position } = calcNextPosition(node, node.computedPosition, nodeExtent, parentNode)
onMounted(() => { node.computedPosition = { ...node.computedPosition, ...position }
until(initialized) })
.toBe(true)
.then(() => {
const { position } = calcNextPosition(node, node.computedPosition, nodeExtent, parentNode)
node.computedPosition = { ...node.computedPosition, ...position }
})
})
function updateInternals() { function updateInternals() {
if (nodeElement.value) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }]) if (nodeElement.value) updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])