@html-graph/html-graph 8.20.0 → 8.21.0

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 CHANGED
@@ -36,4 +36,8 @@ const canvas = new CanvasBuilder(element)
36
36
  .build();
37
37
  ```
38
38
 
39
- Visit the <a target="_blank" href="https://html-graph.github.io">DOCUMENTATION</a> for examples and API reference.
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>
@@ -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
 
@@ -2494,10 +2494,24 @@ class VerticalEdgeShape {
2494
2494
  });
2495
2495
  }
2496
2496
  }
2497
+ const boxPortOffsetFn = (params) => {
2498
+ const { direction, radius } = params;
2499
+ const { x, y } = direction;
2500
+ const { horizontal, vertical } = radius;
2501
+ const tg = y / x;
2502
+ const horX = Math.abs(vertical / tg);
2503
+ const vertY = Math.abs(horizontal * tg);
2504
+ const minX = Math.min(horizontal, horX);
2505
+ const minY = Math.min(vertical, vertY);
2506
+ return Math.sqrt(minX * minX + minY * minY);
2507
+ };
2497
2508
  const resolvePortOffsetFn = (offset) => {
2498
2509
  if (typeof offset === "number") {
2499
2510
  return () => offset;
2500
2511
  }
2512
+ if (offset === "box") {
2513
+ return boxPortOffsetFn;
2514
+ }
2501
2515
  return offset;
2502
2516
  };
2503
2517
  const defaultPortOffset = edgeConstants.portOffset;
@@ -2651,17 +2665,6 @@ class DirectEdgeShape {
2651
2665
  });
2652
2666
  }
2653
2667
  }
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
2668
  const createEdgeGroup = () => {
2666
2669
  const group = document.createElementNS("http://www.w3.org/2000/svg", "g");
2667
2670
  group.style.pointerEvents = "auto";