@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.
@@ -1275,6 +1275,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1275
1275
  to: { x: to.x - x, y: to.y - y }
1276
1276
  };
1277
1277
  };
1278
+ const halfCube = 0.5 * 0.5 * 0.5;
1279
+ const halfCube3 = 3 * halfCube;
1278
1280
  class BezierEdgePath {
1279
1281
  constructor(params) {
1280
1282
  __publicField(this, "path");
@@ -1289,9 +1291,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1289
1291
  hasSourceArrow,
1290
1292
  hasTargetArrow
1291
1293
  } = params;
1292
- const centerX = (from.x + to.x) / 2;
1293
- const centerY = (from.y + to.y) / 2;
1294
- this.midpoint = { x: centerX, y: centerY };
1295
1294
  const begin = createRotatedPoint(
1296
1295
  { x: from.x + arrowLength, y: from.y },
1297
1296
  fromDir,
@@ -1310,6 +1309,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1310
1309
  x: end.x - toDir.x * curvature,
1311
1310
  y: end.y - toDir.y * curvature
1312
1311
  };
1312
+ const centerX = halfCube * begin.x + halfCube3 * bezierBegin.x + halfCube3 * bezierEnd.x + halfCube * end.x;
1313
+ const centerY = halfCube * begin.y + halfCube3 * bezierBegin.y + halfCube3 * bezierEnd.y + halfCube * end.y;
1314
+ this.midpoint = { x: centerX, y: centerY };
1313
1315
  const curve = `M ${begin.x} ${begin.y} C ${bezierBegin.x} ${bezierBegin.y}, ${bezierEnd.x} ${bezierEnd.y}, ${end.x} ${end.y}`;
1314
1316
  const preLine = hasSourceArrow ? "" : `M ${from.x} ${from.y} L ${begin.x} ${begin.y} `;
1315
1317
  const postLine = hasTargetArrow ? "" : ` M ${end.x} ${end.y} L ${to.x} ${to.y}`;
@@ -2498,10 +2500,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2498
2500
  });
2499
2501
  }
2500
2502
  }
2503
+ const boxPortOffsetFn = (params) => {
2504
+ const { direction, radius } = params;
2505
+ const { x, y } = direction;
2506
+ const { horizontal, vertical } = radius;
2507
+ const tg = y / x;
2508
+ const horX = Math.abs(vertical / tg);
2509
+ const vertY = Math.abs(horizontal * tg);
2510
+ const minX = Math.min(horizontal, horX);
2511
+ const minY = Math.min(vertical, vertY);
2512
+ return Math.sqrt(minX * minX + minY * minY);
2513
+ };
2501
2514
  const resolvePortOffsetFn = (offset) => {
2502
2515
  if (typeof offset === "number") {
2503
2516
  return () => offset;
2504
2517
  }
2518
+ if (offset === "box") {
2519
+ return boxPortOffsetFn;
2520
+ }
2505
2521
  return offset;
2506
2522
  };
2507
2523
  const defaultPortOffset = edgeConstants.portOffset;
@@ -2655,17 +2671,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2655
2671
  });
2656
2672
  }
2657
2673
  }
2658
- const boxPortOffsetFn = (params) => {
2659
- const { direction, radius } = params;
2660
- const { x, y } = direction;
2661
- const { horizontal, vertical } = radius;
2662
- const tg = y / x;
2663
- const horX = Math.abs(vertical / tg);
2664
- const vertY = Math.abs(horizontal * tg);
2665
- const minX = Math.min(horizontal, horX);
2666
- const minY = Math.min(vertical, vertY);
2667
- return Math.sqrt(minX * minX + minY * minY);
2668
- };
2669
2674
  const createEdgeGroup = () => {
2670
2675
  const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2671
2676
  group.style.pointerEvents = "auto";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@html-graph/html-graph",
3
3
  "author": "Dmitry Marov <d.marov94@gmail.com>",
4
4
  "private": false,
5
- "version": "8.20.0",
5
+ "version": "8.21.1",
6
6
  "type": "module",
7
7
  "main": "dist/html-graph.js",
8
8
  "types": "dist/html-graph.d.ts",
@@ -70,5 +70,10 @@
70
70
  "vite": "^5.4.1",
71
71
  "vite-plugin-checker": "^0.7.2",
72
72
  "vite-plugin-dts": "^4.0.3"
73
- }
73
+ },
74
+ "os": [
75
+ "darwin",
76
+ "linux",
77
+ "win32"
78
+ ]
74
79
  }