@krainovsd/graph 0.11.0 → 0.11.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/lib/cjs/index.cjs CHANGED
@@ -2236,9 +2236,7 @@ function initResize() {
2236
2236
  observer.disconnect();
2237
2237
  return;
2238
2238
  }
2239
- requestAnimationFrame(() => {
2240
- this.updateSize();
2241
- });
2239
+ this.updateSize();
2242
2240
  });
2243
2241
  document.addEventListener("scroll", this.updateRect.bind(this), {
2244
2242
  capture: true,
@@ -2552,8 +2550,20 @@ class GraphCanvas {
2552
2550
  this.tick();
2553
2551
  }
2554
2552
  updateRect() {
2555
- if (this.area)
2556
- this.areaRect = this.area.getBoundingClientRect();
2553
+ if (!this.area)
2554
+ return;
2555
+ this.areaRect = this.area.getBoundingClientRect();
2556
+ }
2557
+ updateSize() {
2558
+ if (!this.area)
2559
+ return;
2560
+ const { width, height } = this.root.getBoundingClientRect();
2561
+ this.width = width;
2562
+ this.height = height;
2563
+ this.area.width = this.dpi * this.width;
2564
+ this.area.height = this.dpi * this.height;
2565
+ this.areaRect = this.area.getBoundingClientRect();
2566
+ this.draw();
2557
2567
  }
2558
2568
  clearCache(keys) {
2559
2569
  if (!keys) {
@@ -2647,16 +2657,6 @@ class GraphCanvas {
2647
2657
  .restart();
2648
2658
  }
2649
2659
  }
2650
- updateSize() {
2651
- this.clearHTMLElements();
2652
- initArea.call(this);
2653
- initDnd.call(this);
2654
- initZoom.call(this);
2655
- initResize.call(this);
2656
- initPointer.call(this);
2657
- if (!this.simulationWorking && !this.highlightWorking)
2658
- this.draw();
2659
- }
2660
2660
  init() {
2661
2661
  initArea.call(this);
2662
2662
  initSimulation.call(this);