fix(edges): edge text not aligning correctly into center
This commit is contained in:
@@ -13,13 +13,17 @@ const {
|
|||||||
labelBgBorderRadius = 2,
|
labelBgBorderRadius = 2,
|
||||||
} = defineProps<EdgeTextProps>()
|
} = defineProps<EdgeTextProps>()
|
||||||
|
|
||||||
const el = ref<SVGTextElement>()
|
|
||||||
|
|
||||||
let box = $ref<RectType>({ x: 0, y: 0, width: 0, height: 0 })
|
let box = $ref<RectType>({ x: 0, y: 0, width: 0, height: 0 })
|
||||||
|
|
||||||
onMounted(() => {
|
const el = (el: any) => {
|
||||||
box = el.value!.getBBox()
|
if (!el) return
|
||||||
})
|
|
||||||
|
const nextBox = el.getBBox()
|
||||||
|
|
||||||
|
if (nextBox.width !== box.width || nextBox.height !== box.height) {
|
||||||
|
box = nextBox
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`)
|
const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user