Skip to content

Commit cbfe69a

Browse files
committed
wip
1 parent 0a5909b commit cbfe69a

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

packages/joint-core/src/routers/rightAngle.mjs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ function moveAndExpandBBox(bbox, direction, margin) {
465465
function routeBetweenPoints(source, target, opt = {}) {
466466
const { point: sourcePoint, x0: sx0, y0: sy0, width: sourceWidth, height: sourceHeight, margin: sourceMargin } = source;
467467
const { point: targetPoint, x0: tx0, y0: ty0, width: targetWidth, height: targetHeight, margin: targetMargin } = target;
468-
const { targetInSourceBBox = false, ignoreOverlappingMargin } = opt;
468+
const { targetInSourceBBox = false, minMargin } = opt;
469469

470470
const tx1 = tx0 + targetWidth;
471471
const ty1 = ty0 + targetHeight;
@@ -544,9 +544,9 @@ function routeBetweenPoints(source, target, opt = {}) {
544544
const isUpwardsShorter = topD < bottomD;
545545

546546
let ignoreMargin = false;
547-
if (ignoreOverlappingMargin &&
548-
((Math.abs(smy1 - tmy0) <= ignoreOverlappingMargin) ||
549-
(Math.abs(smy0 - tmy1) <= ignoreOverlappingMargin))) {
547+
if (minMargin &&
548+
((Math.abs(smy1 - tmy0) <= minMargin) ||
549+
(Math.abs(smy0 - tmy1) <= minMargin))) {
550550
ignoreMargin = true;
551551
}
552552

@@ -611,9 +611,9 @@ function routeBetweenPoints(source, target, opt = {}) {
611611
const isUpwardsShorter = topD < bottomD;
612612

613613
let ignoreMargin = false;
614-
if (ignoreOverlappingMargin &&
615-
((Math.abs(smy1 - tmy0) <= ignoreOverlappingMargin) ||
616-
(Math.abs(smy0 - tmy1) <= ignoreOverlappingMargin))) {
614+
if (minMargin &&
615+
((Math.abs(smy1 - tmy0) <= minMargin) ||
616+
(Math.abs(smy0 - tmy1) <= minMargin))) {
617617
ignoreMargin = true;
618618
}
619619

@@ -678,9 +678,9 @@ function routeBetweenPoints(source, target, opt = {}) {
678678
const isLeftShorter = leftD < rightD;
679679

680680
let ignoreMargin = false;
681-
if (ignoreOverlappingMargin &&
682-
((Math.abs(smx1 - tmx0) <= ignoreOverlappingMargin) ||
683-
(Math.abs(smx0 - tmx1) <= ignoreOverlappingMargin))) {
681+
if (minMargin &&
682+
((Math.abs(smx1 - tmx0) <= minMargin) ||
683+
(Math.abs(smx0 - tmx1) <= minMargin))) {
684684
ignoreMargin = true;
685685
}
686686

@@ -745,9 +745,9 @@ function routeBetweenPoints(source, target, opt = {}) {
745745
const isLeftShorter = leftD < rightD;
746746

747747
let ignoreMargin = false;
748-
if (ignoreOverlappingMargin &&
749-
((Math.abs(smx1 - tmx0) <= ignoreOverlappingMargin) ||
750-
(Math.abs(smx0 - tmx1) <= ignoreOverlappingMargin))) {
748+
if (minMargin &&
749+
((Math.abs(smx1 - tmx0) <= minMargin) ||
750+
(Math.abs(smx0 - tmx1) <= minMargin))) {
751751
ignoreMargin = true;
752752
}
753753

@@ -1536,7 +1536,7 @@ function getLoopCoordinates(direction, angle, margin) {
15361536
}
15371537

15381538
function rightAngleRouter(vertices, opt, linkView) {
1539-
const { sourceDirection = Directions.AUTO, targetDirection = Directions.AUTO, ignoreOverlappingMargin = null } = opt;
1539+
const { sourceDirection = Directions.AUTO, targetDirection = Directions.AUTO, minMargin = null } = opt;
15401540
const margin = opt.margin || 20;
15411541
const useVertices = opt.useVertices || false;
15421542

@@ -1549,7 +1549,7 @@ function rightAngleRouter(vertices, opt, linkView) {
15491549
const resultVertices = [];
15501550

15511551
if (!useVertices || vertices.length === 0) {
1552-
return simplifyPoints(routeBetweenPoints(sourcePoint, targetPoint, { ignoreOverlappingMargin }));
1552+
return simplifyPoints(routeBetweenPoints(sourcePoint, targetPoint, { minMargin }));
15531553
}
15541554

15551555
const verticesData = vertices.map((v) => pointDataFromVertex(v));
@@ -1595,15 +1595,15 @@ function rightAngleRouter(vertices, opt, linkView) {
15951595
// No need to create a route, use the `routeBetweenPoints` to construct a route
15961596
firstVertex.direction = resolvedSourceDirection;
15971597
firstVertex.margin = margin;
1598-
resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex, { targetInSourceBBox: true, ignoreOverlappingMargin }), firstVertex.point);
1598+
resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex, { targetInSourceBBox: true, minMargin }), firstVertex.point);
15991599
}
16001600
} else {
16011601
// The first point responsible for the initial direction of the route
16021602
const next = verticesData[1] || targetPoint;
16031603
const direction = resolveInitialDirection(sourcePoint, firstVertex, next);
16041604
firstVertex.direction = direction;
16051605

1606-
resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex, { ignoreOverlappingMargin }), firstVertex.point);
1606+
resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex, { minMargin }), firstVertex.point);
16071607
}
16081608

16091609
for (let i = 0; i < verticesData.length - 1; i++) {
@@ -1654,7 +1654,7 @@ function rightAngleRouter(vertices, opt, linkView) {
16541654
from.direction = fromDirection;
16551655
to.direction = toDirection;
16561656

1657-
resultVertices.push(...routeBetweenPoints(from, to, { ignoreOverlappingMargin }), to.point);
1657+
resultVertices.push(...routeBetweenPoints(from, to, { minMargin }), to.point);
16581658
}
16591659

16601660
const lastVertex = verticesData[verticesData.length - 1];
@@ -1676,7 +1676,7 @@ function rightAngleRouter(vertices, opt, linkView) {
16761676

16771677
lastVertex.direction = definedDirection;
16781678

1679-
let lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { ignoreOverlappingMargin });
1679+
let lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { minMargin });
16801680
const [p1, p2] = simplifyPoints([...lastSegmentRoute, targetPoint.point]);
16811681

16821682
const lastSegment = new g.Line(p1, p2);
@@ -1701,10 +1701,10 @@ function rightAngleRouter(vertices, opt, linkView) {
17011701
} else if (isVertexInside && resolvedTargetDirection !== OPPOSITE_DIRECTIONS[definedDirection]) {
17021702
lastVertex.margin = margin;
17031703
lastVertex.direction = resolvedTargetDirection;
1704-
lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { ignoreOverlappingMargin });
1704+
lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { minMargin });
17051705
} else if (lastSegmentDirection !== definedDirection && definedDirection === OPPOSITE_DIRECTIONS[lastSegmentDirection]) {
17061706
lastVertex.margin = margin;
1707-
lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { ignoreOverlappingMargin });
1707+
lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint, { minMargin });
17081708
}
17091709

17101710
resultVertices.push(...lastSegmentRoute);
@@ -1745,7 +1745,7 @@ function rightAngleRouter(vertices, opt, linkView) {
17451745
from.direction = fromDirection;
17461746
to.direction = toDirection;
17471747

1748-
resultVertices.push(...routeBetweenPoints(from, to, { ignoreOverlappingMargin }));
1748+
resultVertices.push(...routeBetweenPoints(from, to, { minMargin }));
17491749
}
17501750
}
17511751

0 commit comments

Comments
 (0)