force-graph 1.49.0 → 1.49.2

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.
@@ -1,4 +1,4 @@
1
- // Version 1.49.0 force-graph - https://github.com/vasturiano/force-graph
1
+ // Version 1.49.2 force-graph - https://github.com/vasturiano/force-graph
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -3741,6 +3741,18 @@
3741
3741
  return min;
3742
3742
  }
3743
3743
 
3744
+ function sum(values, valueof) {
3745
+ let sum = 0;
3746
+ {
3747
+ for (let value of values) {
3748
+ if (value = +value) {
3749
+ sum += value;
3750
+ }
3751
+ }
3752
+ }
3753
+ return sum;
3754
+ }
3755
+
3744
3756
  /** Detect free variable `global` from Node.js. */
3745
3757
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3746
3758
 
@@ -11974,6 +11986,7 @@
11974
11986
 
11975
11987
  var HOVER_CANVAS_THROTTLE_DELAY = 800; // ms to throttle shadow canvas updates for perf improvement
11976
11988
  var ZOOM2NODES_FACTOR = 4;
11989
+ var DRAG_CLICK_TOLERANCE_PX = 5; // How many px can a node be accidentally dragged before disabling the click
11977
11990
 
11978
11991
  // Expose config from forceGraph
11979
11992
  var bindFG = linkKapsule('forceGraph', CanvasForceGraph);
@@ -12447,17 +12460,20 @@
12447
12460
  var initPos = obj.__initialDragPos;
12448
12461
  var dragPos = ev;
12449
12462
  var k = transform(state.canvas).k;
12450
- var translate = {
12451
- x: initPos.x + (dragPos.x - initPos.x) / k - obj.x,
12452
- y: initPos.y + (dragPos.y - initPos.y) / k - obj.y
12453
- };
12454
12463
 
12455
12464
  // Move fx/fy (and x/y) of nodes based on the scaled drag distance since the drag start
12456
12465
  ['x', 'y'].forEach(function (c) {
12457
12466
  return obj["f".concat(c)] = obj[c] = initPos[c] + (dragPos[c] - initPos[c]) / k;
12458
12467
  });
12459
12468
 
12460
- // prevent freeze while dragging
12469
+ // Only engage full drag if distance reaches above threshold
12470
+ if (!obj.__dragged && DRAG_CLICK_TOLERANCE_PX >= Math.sqrt(sum(['x', 'y'].map(function (k) {
12471
+ return Math.pow(ev[k] - initPos[k], 2);
12472
+ })))) return;
12473
+ var translate = {
12474
+ x: initPos.x + (dragPos.x - initPos.x) / k - obj.x,
12475
+ y: initPos.y + (dragPos.y - initPos.y) / k - obj.y
12476
+ };
12461
12477
  state.forceGraph.d3AlphaTarget(0.3) // keep engine running at low intensity throughout drag
12462
12478
  .resetCountdown(); // prevent freeze while dragging
12463
12479