@html-graph/html-graph 8.20.0 → 8.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/html-graph.d.ts +1 -1
- package/dist/html-graph.js +19 -14
- package/dist/html-graph.min.js +446 -446
- package/dist/html-graph.min.umd.cjs +1 -1
- package/dist/html-graph.umd.cjs +19 -14
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -36,4 +36,8 @@ const canvas = new CanvasBuilder(element)
|
|
|
36
36
|
.build();
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
## Links
|
|
40
|
+
|
|
41
|
+
- <a target="_blank" href="https://html-graph.github.io">Documentation</a>
|
|
42
|
+
- <a target="_blank" href="https://github.com/html-graph/html-graph/blob/master/CONTRIBUTING.md">Contributing</a>
|
|
43
|
+
- <a target="_blank" href="https://github.com/html-graph/html-graph/blob/master/DEVELOPMENT.md">Development</a>
|
package/dist/html-graph.d.ts
CHANGED
|
@@ -854,7 +854,7 @@ export declare interface Point {
|
|
|
854
854
|
|
|
855
855
|
export declare type PortElement = HTMLElement | SVGElement;
|
|
856
856
|
|
|
857
|
-
export declare type PortOffset = number | PortOffsetFn;
|
|
857
|
+
export declare type PortOffset = number | PortOffsetFn | "box";
|
|
858
858
|
|
|
859
859
|
export declare type PortOffsetFn = (params: PortOffsetFnParams) => number;
|
|
860
860
|
|
package/dist/html-graph.js
CHANGED
|
@@ -1271,6 +1271,8 @@ const createEdgeRectangle = (source, target, padding) => {
|
|
|
1271
1271
|
to: { x: to.x - x, y: to.y - y }
|
|
1272
1272
|
};
|
|
1273
1273
|
};
|
|
1274
|
+
const halfCube = 0.5 * 0.5 * 0.5;
|
|
1275
|
+
const halfCube3 = 3 * halfCube;
|
|
1274
1276
|
class BezierEdgePath {
|
|
1275
1277
|
constructor(params) {
|
|
1276
1278
|
__publicField(this, "path");
|
|
@@ -1285,9 +1287,6 @@ class BezierEdgePath {
|
|
|
1285
1287
|
hasSourceArrow,
|
|
1286
1288
|
hasTargetArrow
|
|
1287
1289
|
} = params;
|
|
1288
|
-
const centerX = (from.x + to.x) / 2;
|
|
1289
|
-
const centerY = (from.y + to.y) / 2;
|
|
1290
|
-
this.midpoint = { x: centerX, y: centerY };
|
|
1291
1290
|
const begin = createRotatedPoint(
|
|
1292
1291
|
{ x: from.x + arrowLength, y: from.y },
|
|
1293
1292
|
fromDir,
|
|
@@ -1306,6 +1305,9 @@ class BezierEdgePath {
|
|
|
1306
1305
|
x: end.x - toDir.x * curvature,
|
|
1307
1306
|
y: end.y - toDir.y * curvature
|
|
1308
1307
|
};
|
|
1308
|
+
const centerX = halfCube * begin.x + halfCube3 * bezierBegin.x + halfCube3 * bezierEnd.x + halfCube * end.x;
|
|
1309
|
+
const centerY = halfCube * begin.y + halfCube3 * bezierBegin.y + halfCube3 * bezierEnd.y + halfCube * end.y;
|
|
1310
|
+
this.midpoint = { x: centerX, y: centerY };
|
|
1309
1311
|
const curve = `M ${begin.x} ${begin.y} C ${bezierBegin.x} ${bezierBegin.y}, ${bezierEnd.x} ${bezierEnd.y}, ${end.x} ${end.y}`;
|
|
1310
1312
|
const preLine = hasSourceArrow ? "" : `M ${from.x} ${from.y} L ${begin.x} ${begin.y} `;
|
|
1311
1313
|
const postLine = hasTargetArrow ? "" : ` M ${end.x} ${end.y} L ${to.x} ${to.y}`;
|
|
@@ -2494,10 +2496,24 @@ class VerticalEdgeShape {
|
|
|
2494
2496
|
});
|
|
2495
2497
|
}
|
|
2496
2498
|
}
|
|
2499
|
+
const boxPortOffsetFn = (params) => {
|
|
2500
|
+
const { direction, radius } = params;
|
|
2501
|
+
const { x, y } = direction;
|
|
2502
|
+
const { horizontal, vertical } = radius;
|
|
2503
|
+
const tg = y / x;
|
|
2504
|
+
const horX = Math.abs(vertical / tg);
|
|
2505
|
+
const vertY = Math.abs(horizontal * tg);
|
|
2506
|
+
const minX = Math.min(horizontal, horX);
|
|
2507
|
+
const minY = Math.min(vertical, vertY);
|
|
2508
|
+
return Math.sqrt(minX * minX + minY * minY);
|
|
2509
|
+
};
|
|
2497
2510
|
const resolvePortOffsetFn = (offset) => {
|
|
2498
2511
|
if (typeof offset === "number") {
|
|
2499
2512
|
return () => offset;
|
|
2500
2513
|
}
|
|
2514
|
+
if (offset === "box") {
|
|
2515
|
+
return boxPortOffsetFn;
|
|
2516
|
+
}
|
|
2501
2517
|
return offset;
|
|
2502
2518
|
};
|
|
2503
2519
|
const defaultPortOffset = edgeConstants.portOffset;
|
|
@@ -2651,17 +2667,6 @@ class DirectEdgeShape {
|
|
|
2651
2667
|
});
|
|
2652
2668
|
}
|
|
2653
2669
|
}
|
|
2654
|
-
const boxPortOffsetFn = (params) => {
|
|
2655
|
-
const { direction, radius } = params;
|
|
2656
|
-
const { x, y } = direction;
|
|
2657
|
-
const { horizontal, vertical } = radius;
|
|
2658
|
-
const tg = y / x;
|
|
2659
|
-
const horX = Math.abs(vertical / tg);
|
|
2660
|
-
const vertY = Math.abs(horizontal * tg);
|
|
2661
|
-
const minX = Math.min(horizontal, horX);
|
|
2662
|
-
const minY = Math.min(vertical, vertY);
|
|
2663
|
-
return Math.sqrt(minX * minX + minY * minY);
|
|
2664
|
-
};
|
|
2665
2670
|
const createEdgeGroup = () => {
|
|
2666
2671
|
const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
2667
2672
|
group.style.pointerEvents = "auto";
|