fix(edges): edge text height not centered
Signed-off-by: bcakmakoglu <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,9 @@ const props = withDefaults(defineProps<EdgeTextProps>(), {
|
|||||||
const { transform: paneTransform } = useVueFlow()
|
const { transform: paneTransform } = useVueFlow()
|
||||||
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
||||||
const { width, height } = useElementBounding(edgeRef)
|
const { width, height } = useElementBounding(edgeRef)
|
||||||
const transform = computed(() => `translate(${props.x - width.value / paneTransform.value[2] / 2} ${props.y - height.value / 2})`)
|
const transform = computed(
|
||||||
|
() => `translate(${props.x - width.value / paneTransform.value[2] / 2} ${props.y - height.value / paneTransform.value[2] / 2})`,
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -26,14 +28,14 @@ export default {
|
|||||||
v-if="props.labelShowBg"
|
v-if="props.labelShowBg"
|
||||||
class="vue-flow__edge-textbg"
|
class="vue-flow__edge-textbg"
|
||||||
:width="width / paneTransform[2] + 2 * props.labelBgPadding[0] + 'px'"
|
:width="width / paneTransform[2] + 2 * props.labelBgPadding[0] + 'px'"
|
||||||
:height="height + 2 * props.labelBgPadding[1] + 'px'"
|
:height="height / paneTransform[2] + 2 * props.labelBgPadding[1] + 'px'"
|
||||||
:x="-props.labelBgPadding[0]"
|
:x="-props.labelBgPadding[0]"
|
||||||
:y="-props.labelBgPadding[1]"
|
:y="-props.labelBgPadding[1]"
|
||||||
:style="props.labelBgStyle"
|
:style="props.labelBgStyle"
|
||||||
:rx="props.labelBgBorderRadius"
|
:rx="props.labelBgBorderRadius"
|
||||||
:ry="props.labelBgBorderRadius"
|
:ry="props.labelBgBorderRadius"
|
||||||
/>
|
/>
|
||||||
<text ref="edge-text" class="vue-flow__edge-text" :y="height / 2" dy="0.3em" :style="props.labelStyle">
|
<text ref="edge-text" class="vue-flow__edge-text" :y="height / paneTransform[2] / 2" dy="0.3em" :style="props.labelStyle">
|
||||||
<slot v-bind="props">
|
<slot v-bind="props">
|
||||||
<component
|
<component
|
||||||
:is="props.label?.component"
|
:is="props.label?.component"
|
||||||
|
|||||||
Reference in New Issue
Block a user