From d4fb7957879d70c2ef7cc9cad02ba85d378c6be2 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:47:20 +0200 Subject: [PATCH] fix(edges): edge text not properly calculating dimensions --- packages/core/src/components/Edges/EdgeText.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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})`)