Skip to content

Commit d4fb795

Browse files
committed
fix(edges): edge text not properly calculating dimensions
1 parent a226e6a commit d4fb795

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/core/src/components/Edges/EdgeText.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const {
1515
1616
let box = $ref<RectType>({ x: 0, y: 0, width: 0, height: 0 })
1717
18-
const el = (el: any) => {
18+
const el = $ref<SVGTextElement | null>(null)
19+
20+
const getBox = () => {
1921
if (!el) return
2022
2123
const nextBox = el.getBBox()
@@ -25,6 +27,10 @@ const el = (el: any) => {
2527
}
2628
}
2729
30+
onMounted(getBox)
31+
32+
watch([() => x, () => y, $$(el), () => label], getBox)
33+
2834
const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`)
2935
</script>
3036

0 commit comments

Comments
 (0)