@krainovsd/graph 0.8.1 → 0.8.3

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/lib/cjs/index.cjs CHANGED
@@ -1586,10 +1586,13 @@ class GraphCanvas {
1586
1586
  this.nodeOptionsCache[node.id] = nodeOptions;
1587
1587
  }
1588
1588
  }
1589
- if (nodeOptions.nodeDraw) {
1589
+ if (nodeOptions.nodeDraw && nodeOptions.textDraw) {
1590
1590
  nodeRenders.push(() => {
1591
1591
  nodeOptions?.nodeDraw?.(node, nodeOptions, state);
1592
1592
  });
1593
+ textRenders.push(() => {
1594
+ nodeOptions?.textDraw?.(node, nodeOptions, state);
1595
+ });
1593
1596
  return;
1594
1597
  }
1595
1598
  let alpha = nodeOptions.alpha;
@@ -1673,6 +1676,22 @@ class GraphCanvas {
1673
1676
  this.context.fill();
1674
1677
  this.context.stroke();
1675
1678
  });
1679
+ if (nodeOptions.nodeExtraDraw) {
1680
+ nodeRenders.push(() => {
1681
+ nodeOptions?.nodeExtraDraw?.(node, {
1682
+ ...nodeOptions,
1683
+ radius,
1684
+ alpha,
1685
+ color,
1686
+ textAlpha,
1687
+ textSize,
1688
+ textShiftX,
1689
+ textShiftY,
1690
+ textWeight,
1691
+ textWidth,
1692
+ }, state);
1693
+ });
1694
+ }
1676
1695
  /** text */
1677
1696
  if (nodeOptions.textVisible && nodeOptions.text) {
1678
1697
  textRenders.push(() => {
@@ -1727,22 +1746,6 @@ class GraphCanvas {
1727
1746
  }
1728
1747
  });
1729
1748
  }
1730
- if (nodeOptions.nodeExtraDraw) {
1731
- nodeRenders.push(() => {
1732
- nodeOptions?.nodeExtraDraw?.(node, {
1733
- ...nodeOptions,
1734
- radius,
1735
- alpha,
1736
- color,
1737
- textAlpha,
1738
- textSize,
1739
- textShiftX,
1740
- textShiftY,
1741
- textWeight,
1742
- textWidth,
1743
- }, state);
1744
- });
1745
- }
1746
1749
  };
1747
1750
  }
1748
1751
  if (this.graphSettings.showDrawTime) {
@@ -1768,6 +1771,15 @@ class GraphCanvas {
1768
1771
  this.updateSize();
1769
1772
  });
1770
1773
  });
1774
+ function updateRect() {
1775
+ if (this.area)
1776
+ this.areaRect = this.area.getBoundingClientRect();
1777
+ }
1778
+ document.addEventListener("scroll", updateRect.bind(this), {
1779
+ capture: true,
1780
+ passive: true,
1781
+ signal: abortController.signal,
1782
+ });
1771
1783
  observer.observe(this.area);
1772
1784
  }
1773
1785
  initPointer() {