@krainovsd/graph 0.14.0-beta.6 → 0.14.0-beta.8

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
@@ -1322,6 +1322,7 @@ function initArea() {
1322
1322
  if (!this.context)
1323
1323
  throw new Error("couldn't create canvas context");
1324
1324
  this.context.scale(this.dpi, this.dpi);
1325
+ this.updateRect();
1325
1326
  }
1326
1327
  }
1327
1328
 
@@ -2163,7 +2164,7 @@ function initPointer() {
2163
2164
  this.area.style.cursor = "default";
2164
2165
  }
2165
2166
  this.animateHighlight(highlightNode ? currentNode : undefined, highlightLink ? currentLink : undefined);
2166
- if (!this.listeners.onMove)
2167
+ if (!this.listeners.onHover)
2167
2168
  return;
2168
2169
  if (!currentNode && !checkHighlightNode) {
2169
2170
  const [pointerX, pointerY] = this.getPointerAreaPosition(event);
@@ -2183,8 +2184,7 @@ function initPointer() {
2183
2184
  curve: this.linkSettings.curve,
2184
2185
  });
2185
2186
  }
2186
- if (!currentNode)
2187
- return void this.listeners.onMove.call(this, event, currentNode, currentLink);
2187
+ this.listeners.onHover.call(this, event, currentNode, currentLink);
2188
2188
  }
2189
2189
  function onWheelClick(event) {
2190
2190
  if (this.isDragging ||
@@ -2327,8 +2327,20 @@ function initResize() {
2327
2327
  signal: abortController.signal,
2328
2328
  });
2329
2329
  document.addEventListener("visibilitychange", () => {
2330
- if (!document.hidden)
2330
+ if (document.hidden) {
2331
+ this.highlightController?.abort();
2332
+ this.highlightedNode = null;
2333
+ this.highlightedLink = null;
2334
+ this.highlightedNeighbors = null;
2335
+ this.highlightProgress = 0;
2336
+ this.highlightStart = null;
2337
+ this.highlightPositive = false;
2338
+ return;
2339
+ }
2340
+ this.updateSize();
2341
+ requestAnimationFrame(() => {
2331
2342
  this.updateSize();
2343
+ });
2332
2344
  }, { signal: abortController.signal });
2333
2345
  observer.observe(this.area);
2334
2346
  }
@@ -3371,7 +3383,7 @@ class GraphCanvas {
3371
3383
  if (controller.signal.aborted)
3372
3384
  return;
3373
3385
  const elapsed = performance.now() - startTime;
3374
- const t = Math.min(elapsed / duration, 1);
3386
+ const t = duration === 0 ? 1 : Math.min(elapsed / duration, 1);
3375
3387
  const current = startProgress + delta * t;
3376
3388
  const eased = current < 0.5 ? 4 * current * current * current : 1 - (-2 * current + 2) ** 3 / 2;
3377
3389
  this.highlightProgress = eased;