fix(step-edge): always center align label

This commit is contained in:
Kenny Williams
2025-07-09 18:08:01 -07:00
parent 772f53a27d
commit 630b2385e2
2 changed files with 91 additions and 8 deletions
@@ -103,14 +103,17 @@ function getPoints({
targetY: target.y,
});
// Calculate bend position based on the stepPosition parameter
const bendX = sourceGapped.x + (targetGapped.x - sourceGapped.x) * stepPosition;
const bendY = sourceGapped.y + (targetGapped.y - sourceGapped.y) * stepPosition;
// opposite handle positions, default case
if (sourceDir[dirAccessor] * targetDir[dirAccessor] === -1) {
centerX = center.x ?? bendX;
centerY = center.y ?? bendY;
if (dirAccessor === 'x') {
// Primary direction is horizontal, so stepPosition affects X coordinate
centerX = center.x ?? (sourceGapped.x + (targetGapped.x - sourceGapped.x) * stepPosition);
centerY = center.y ?? (sourceGapped.y + targetGapped.y) / 2;
} else {
// Primary direction is vertical, so stepPosition affects Y coordinate
centerX = center.x ?? (sourceGapped.x + targetGapped.x) / 2;
centerY = center.y ?? (sourceGapped.y + (targetGapped.y - sourceGapped.y) * stepPosition);
}
/*
* --->