diff --git a/packages/core/src/components/Edges/EdgeText.vue b/packages/core/src/components/Edges/EdgeText.vue index 642425cf..752847b6 100644 --- a/packages/core/src/components/Edges/EdgeText.vue +++ b/packages/core/src/components/Edges/EdgeText.vue @@ -15,7 +15,9 @@ const { let box = $ref({ x: 0, y: 0, width: 0, height: 0 }) -const el = (el: any) => { +const el = $ref(null) + +const getBox = () => { if (!el) return const nextBox = el.getBBox() @@ -25,6 +27,10 @@ const el = (el: any) => { } } +onMounted(getBox) + +watch([() => x, () => y, $$(el), () => label], getBox) + const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`)