@krainovsd/graph 0.14.0-beta.7 → 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
@@ -2164,7 +2164,7 @@ function initPointer() {
2164
2164
  this.area.style.cursor = "default";
2165
2165
  }
2166
2166
  this.animateHighlight(highlightNode ? currentNode : undefined, highlightLink ? currentLink : undefined);
2167
- if (!this.listeners.onMove)
2167
+ if (!this.listeners.onHover)
2168
2168
  return;
2169
2169
  if (!currentNode && !checkHighlightNode) {
2170
2170
  const [pointerX, pointerY] = this.getPointerAreaPosition(event);
@@ -2184,8 +2184,7 @@ function initPointer() {
2184
2184
  curve: this.linkSettings.curve,
2185
2185
  });
2186
2186
  }
2187
- if (!currentNode)
2188
- return void this.listeners.onMove.call(this, event, currentNode, currentLink);
2187
+ this.listeners.onHover.call(this, event, currentNode, currentLink);
2189
2188
  }
2190
2189
  function onWheelClick(event) {
2191
2190
  if (this.isDragging ||
@@ -2328,8 +2327,16 @@ function initResize() {
2328
2327
  signal: abortController.signal,
2329
2328
  });
2330
2329
  document.addEventListener("visibilitychange", () => {
2331
- 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;
2332
2338
  return;
2339
+ }
2333
2340
  this.updateSize();
2334
2341
  requestAnimationFrame(() => {
2335
2342
  this.updateSize();
@@ -3376,7 +3383,7 @@ class GraphCanvas {
3376
3383
  if (controller.signal.aborted)
3377
3384
  return;
3378
3385
  const elapsed = performance.now() - startTime;
3379
- const t = Math.min(elapsed / duration, 1);
3386
+ const t = duration === 0 ? 1 : Math.min(elapsed / duration, 1);
3380
3387
  const current = startProgress + delta * t;
3381
3388
  const eased = current < 0.5 ? 4 * current * current * current : 1 - (-2 * current + 2) ** 3 / 2;
3382
3389
  this.highlightProgress = eased;