fix(edges): edge text not properly calculating dimensions

This commit is contained in:
braks
2022-10-15 00:47:20 +02:00
committed by Braks
parent a226e6a8c7
commit d4fb795787

View File

@@ -15,7 +15,9 @@ const {
let box = $ref<RectType>({ x: 0, y: 0, width: 0, height: 0 })
const el = (el: any) => {
const el = $ref<SVGTextElement | null>(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})`)
</script>