Skip to content

Commit 749b152

Browse files
committed
feat(layout): enhance labelBox function to support end-aligned labels
1 parent 0a96f32 commit 749b152

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/lib/bpmn-layout.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,21 @@ export interface Box {
412412
export function labelBox(n: PlacedNode): Box | null {
413413
const cajas: Box[] = []
414414

415+
// El texto crece hacia la izquierda cuando va alineado al final.
416+
const horizontal = (w: number): { x1: number; x2: number } =>
417+
n.labelAlign === 'end' ? { x1: n.labelX - w, x2: n.labelX } : { x1: n.labelX - w / 2, x2: n.labelX + w / 2 }
418+
415419
if (n.outside && n.lines.length > 0) {
416420
const w = Math.max(...n.lines.map((l) => l.length)) * CHAR_W + 6
417421
const h = n.lines.length * LINE_H + 4
418422
const y1 = n.labelAbove ? n.cy - n.h / 2 - 6 - h : n.cy + n.h / 2 + 4
419-
cajas.push({ x1: n.cx - w / 2, x2: n.cx + w / 2, y1, y2: y1 + h })
423+
cajas.push({ ...horizontal(w), y1, y2: y1 + h })
420424
}
421425

422426
if (n.duracion) {
423427
const w = n.duracion.length * CHAR_W + 10
424428
const y1 = duracionY(n) - 9
425-
cajas.push({ x1: n.cx - w / 2, x2: n.cx + w / 2, y1, y2: y1 + 15 })
429+
cajas.push({ ...horizontal(w), y1, y2: y1 + 15 })
426430
}
427431

428432
if (cajas.length === 0) return null

0 commit comments

Comments
 (0)