Skip to content

Commit 04f7349

Browse files
committed
upd linked-block
1 parent 94d5c44 commit 04f7349

File tree

3 files changed

+94
-28
lines changed

3 files changed

+94
-28
lines changed

lib/metro.js

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32055,19 +32055,42 @@
3205532055
break;
3205632056
}
3205732057
} else {
32058-
const direction = this._getDirection(parent1, parent2);
32059-
if (direction === "horizontal") {
32060-
const controlDistance = Math.abs(dx) * 0.4 + magic;
32061-
cp1x = x1 + (dx > 0 ? controlDistance : -controlDistance);
32062-
cp1y = y1;
32063-
cp2x = x22 - (dx > 0 ? controlDistance : -controlDistance);
32064-
cp2y = y22;
32065-
} else {
32066-
const controlDistance = Math.abs(dy) * 0.4 + magic;
32067-
cp1x = x1;
32068-
cp1y = y1 + (dy > 0 ? controlDistance : -controlDistance);
32069-
cp2x = x22;
32070-
cp2y = y22 - (dy > 0 ? controlDistance : -controlDistance);
32058+
const controlDistance = Math.max(60, distance * 0.3);
32059+
switch (side1) {
32060+
case "north":
32061+
cp1x = x1;
32062+
cp1y = y1 - controlDistance;
32063+
break;
32064+
case "south":
32065+
cp1x = x1;
32066+
cp1y = y1 + controlDistance;
32067+
break;
32068+
case "east":
32069+
cp1x = x1 + controlDistance;
32070+
cp1y = y1;
32071+
break;
32072+
case "west":
32073+
cp1x = x1 - controlDistance;
32074+
cp1y = y1;
32075+
break;
32076+
}
32077+
switch (side2) {
32078+
case "north":
32079+
cp2x = x22;
32080+
cp2y = y22 - controlDistance;
32081+
break;
32082+
case "south":
32083+
cp2x = x22;
32084+
cp2y = y22 + controlDistance;
32085+
break;
32086+
case "east":
32087+
cp2x = x22 + controlDistance;
32088+
cp2y = y22;
32089+
break;
32090+
case "west":
32091+
cp2x = x22 - controlDistance;
32092+
cp2y = y22;
32093+
break;
3207132094
}
3207232095
}
3207332096
const pathData = `M ${x1} ${y1} C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${x22} ${y22}`;

lib/metro.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/components/linked-block/linked-connector.js

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -451,20 +451,63 @@
451451
}
452452
} else {
453453
// Стандартна логіка для точок на різних сторонах
454-
const direction = this._getDirection(parent1, parent2);
454+
// const direction = this._getDirection(parent1, parent2);
455+
//
456+
// if (direction === "horizontal") {
457+
// const controlDistance = Math.abs(dx) * 0.4 + magic;
458+
// cp1x = x1 + (dx > 0 ? controlDistance : -controlDistance);
459+
// cp1y = y1;
460+
// cp2x = x2 - (dx > 0 ? controlDistance : -controlDistance);
461+
// cp2y = y2;
462+
// } else {
463+
// const controlDistance = Math.abs(dy) * 0.4 + magic;
464+
// cp1x = x1;
465+
// cp1y = y1 + (dy > 0 ? controlDistance : -controlDistance);
466+
// cp2x = x2;
467+
// cp2y = y2 - (dy > 0 ? controlDistance : -controlDistance);
468+
// }
469+
470+
const controlDistance = Math.max(60, distance * 0.3);
471+
472+
// Контрольні точки базуються на сторонах точок, а не на загальному напрямку
473+
// Перша контрольна точка (від першої точки)
474+
switch (side1) {
475+
case "north":
476+
cp1x = x1;
477+
cp1y = y1 - controlDistance;
478+
break;
479+
case "south":
480+
cp1x = x1;
481+
cp1y = y1 + controlDistance;
482+
break;
483+
case "east":
484+
cp1x = x1 + controlDistance;
485+
cp1y = y1;
486+
break;
487+
case "west":
488+
cp1x = x1 - controlDistance;
489+
cp1y = y1;
490+
break;
491+
}
455492

456-
if (direction === "horizontal") {
457-
const controlDistance = Math.abs(dx) * 0.4 + magic;
458-
cp1x = x1 + (dx > 0 ? controlDistance : -controlDistance);
459-
cp1y = y1;
460-
cp2x = x2 - (dx > 0 ? controlDistance : -controlDistance);
461-
cp2y = y2;
462-
} else {
463-
const controlDistance = Math.abs(dy) * 0.4 + magic;
464-
cp1x = x1;
465-
cp1y = y1 + (dy > 0 ? controlDistance : -controlDistance);
466-
cp2x = x2;
467-
cp2y = y2 - (dy > 0 ? controlDistance : -controlDistance);
493+
// Друга контрольна точка (до другої точки)
494+
switch (side2) {
495+
case "north":
496+
cp2x = x2;
497+
cp2y = y2 - controlDistance;
498+
break;
499+
case "south":
500+
cp2x = x2;
501+
cp2y = y2 + controlDistance;
502+
break;
503+
case "east":
504+
cp2x = x2 + controlDistance;
505+
cp2y = y2;
506+
break;
507+
case "west":
508+
cp2x = x2 - controlDistance;
509+
cp2y = y2;
510+
break;
468511
}
469512
}
470513

0 commit comments

Comments
 (0)