force-graph 1.43.1 → 1.43.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.43.1 force-graph - https://github.com/vasturiano/force-graph
1
+ // Version 1.43.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) :
@@ -914,13 +914,13 @@
914
914
  });
915
915
  }
916
916
 
917
- function remove$1() {
917
+ function remove() {
918
918
  var parent = this.parentNode;
919
919
  if (parent) parent.removeChild(this);
920
920
  }
921
921
 
922
922
  function selection_remove() {
923
- return this.each(remove$1);
923
+ return this.each(remove);
924
924
  }
925
925
 
926
926
  function selection_cloneShallow() {
@@ -2190,7 +2190,7 @@
2190
2190
  clock = typeof performance === "object" && performance.now ? performance : Date,
2191
2191
  setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
2192
2192
 
2193
- function now$4() {
2193
+ function now$3() {
2194
2194
  return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
2195
2195
  }
2196
2196
 
@@ -2208,7 +2208,7 @@
2208
2208
  constructor: Timer,
2209
2209
  restart: function(callback, delay, time) {
2210
2210
  if (typeof callback !== "function") throw new TypeError("callback is not a function");
2211
- time = (time == null ? now$4() : +time) + (delay == null ? 0 : +delay);
2211
+ time = (time == null ? now$3() : +time) + (delay == null ? 0 : +delay);
2212
2212
  if (!this._next && taskTail !== this) {
2213
2213
  if (taskTail) taskTail._next = this;
2214
2214
  else taskHead = this;
@@ -2234,7 +2234,7 @@
2234
2234
  }
2235
2235
 
2236
2236
  function timerFlush() {
2237
- now$4(); // Get the current time, if not already set.
2237
+ now$3(); // Get the current time, if not already set.
2238
2238
  ++frame; // Pretend we’ve set an alarm, if we haven’t already.
2239
2239
  var t = taskHead, e;
2240
2240
  while (t) {
@@ -3149,7 +3149,7 @@
3149
3149
  if (name instanceof Transition) {
3150
3150
  id = name._id, name = name._name;
3151
3151
  } else {
3152
- id = newId(), (timing = defaultTiming).time = now$4(), name = name == null ? null : name + "";
3152
+ id = newId(), (timing = defaultTiming).time = now$3(), name = name == null ? null : name + "";
3153
3153
  }
3154
3154
 
3155
3155
  for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
@@ -4066,11 +4066,11 @@
4066
4066
  * }, _.now());
4067
4067
  * // => Logs the number of milliseconds it took for the deferred invocation.
4068
4068
  */
4069
- var now$2 = function() {
4069
+ var now$1 = function() {
4070
4070
  return root$1.Date.now();
4071
4071
  };
4072
4072
 
4073
- var now$3 = now$2;
4073
+ var now$2 = now$1;
4074
4074
 
4075
4075
  /** Error message constants. */
4076
4076
  var FUNC_ERROR_TEXT$1 = 'Expected a function';
@@ -4133,7 +4133,7 @@
4133
4133
  * // Cancel the trailing debounced invocation.
4134
4134
  * jQuery(window).on('popstate', debounced.cancel);
4135
4135
  */
4136
- function debounce$1(func, wait, options) {
4136
+ function debounce(func, wait, options) {
4137
4137
  var lastArgs,
4138
4138
  lastThis,
4139
4139
  maxWait,
@@ -4197,7 +4197,7 @@
4197
4197
  }
4198
4198
 
4199
4199
  function timerExpired() {
4200
- var time = now$3();
4200
+ var time = now$2();
4201
4201
  if (shouldInvoke(time)) {
4202
4202
  return trailingEdge(time);
4203
4203
  }
@@ -4226,11 +4226,11 @@
4226
4226
  }
4227
4227
 
4228
4228
  function flush() {
4229
- return timerId === undefined ? result : trailingEdge(now$3());
4229
+ return timerId === undefined ? result : trailingEdge(now$2());
4230
4230
  }
4231
4231
 
4232
4232
  function debounced() {
4233
- var time = now$3(),
4233
+ var time = now$2(),
4234
4234
  isInvoking = shouldInvoke(time);
4235
4235
 
4236
4236
  lastArgs = arguments;
@@ -4316,7 +4316,7 @@
4316
4316
  leading = 'leading' in options ? !!options.leading : leading;
4317
4317
  trailing = 'trailing' in options ? !!options.trailing : trailing;
4318
4318
  }
4319
- return debounce$1(func, wait, {
4319
+ return debounce(func, wait, {
4320
4320
  'leading': leading,
4321
4321
  'maxWait': wait,
4322
4322
  'trailing': trailing
@@ -4538,37 +4538,7 @@
4538
4538
  },
4539
4539
  });
4540
4540
 
4541
- var now;
4542
- // Include a performance.now polyfill.
4543
- // In node.js, use process.hrtime.
4544
- // eslint-disable-next-line
4545
- // @ts-ignore
4546
- if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
4547
- now = function () {
4548
- // eslint-disable-next-line
4549
- // @ts-ignore
4550
- var time = process.hrtime();
4551
- // Convert [seconds, nanoseconds] to milliseconds.
4552
- return time[0] * 1000 + time[1] / 1000000;
4553
- };
4554
- }
4555
- // In a browser, use self.performance.now if it is available.
4556
- else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
4557
- // This must be bound, because directly assigning this function
4558
- // leads to an invocation exception in Chrome.
4559
- now = self.performance.now.bind(self.performance);
4560
- }
4561
- // Use Date.now if it is available.
4562
- else if (Date.now !== undefined) {
4563
- now = Date.now;
4564
- }
4565
- // Otherwise, use 'new Date().getTime()'.
4566
- else {
4567
- now = function () {
4568
- return new Date().getTime();
4569
- };
4570
- }
4571
- var now$1 = now;
4541
+ var now = function () { return performance.now(); };
4572
4542
 
4573
4543
  /**
4574
4544
  * Controlling groups of tweens
@@ -4599,7 +4569,7 @@
4599
4569
  delete this._tweensAddedDuringUpdate[tween.getId()];
4600
4570
  };
4601
4571
  Group.prototype.update = function (time, preserve) {
4602
- if (time === void 0) { time = now$1(); }
4572
+ if (time === void 0) { time = now(); }
4603
4573
  if (preserve === void 0) { preserve = false; }
4604
4574
  var tweenIds = Object.keys(this._tweens);
4605
4575
  if (tweenIds.length === 0) {
@@ -4740,6 +4710,7 @@
4740
4710
  this._valuesEnd = {};
4741
4711
  this._valuesStartRepeat = {};
4742
4712
  this._duration = 1000;
4713
+ this._isDynamic = false;
4743
4714
  this._initialRepeat = 0;
4744
4715
  this._repeat = 0;
4745
4716
  this._yoyo = false;
@@ -4755,6 +4726,7 @@
4755
4726
  this._onEveryStartCallbackFired = false;
4756
4727
  this._id = Sequence.nextId();
4757
4728
  this._isChainStopped = false;
4729
+ this._propertiesAreSetUp = false;
4758
4730
  this._goToEnd = false;
4759
4731
  }
4760
4732
  Tween.prototype.getId = function () {
@@ -4766,24 +4738,27 @@
4766
4738
  Tween.prototype.isPaused = function () {
4767
4739
  return this._isPaused;
4768
4740
  };
4769
- Tween.prototype.to = function (properties, duration) {
4770
- // TODO? restore this, then update the 07_dynamic_to example to set fox
4771
- // tween's to on each update. That way the behavior is opt-in (there's
4772
- // currently no opt-out).
4773
- // for (const prop in properties) this._valuesEnd[prop] = properties[prop]
4774
- this._valuesEnd = Object.create(properties);
4775
- if (duration !== undefined) {
4776
- this._duration = duration;
4777
- }
4741
+ Tween.prototype.to = function (target, duration) {
4742
+ if (duration === void 0) { duration = 1000; }
4743
+ if (this._isPlaying)
4744
+ throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
4745
+ this._valuesEnd = target;
4746
+ this._propertiesAreSetUp = false;
4747
+ this._duration = duration;
4778
4748
  return this;
4779
4749
  };
4780
- Tween.prototype.duration = function (d) {
4781
- if (d === void 0) { d = 1000; }
4782
- this._duration = d;
4750
+ Tween.prototype.duration = function (duration) {
4751
+ if (duration === void 0) { duration = 1000; }
4752
+ this._duration = duration;
4753
+ return this;
4754
+ };
4755
+ Tween.prototype.dynamic = function (dynamic) {
4756
+ if (dynamic === void 0) { dynamic = false; }
4757
+ this._isDynamic = dynamic;
4783
4758
  return this;
4784
4759
  };
4785
4760
  Tween.prototype.start = function (time, overrideStartingValues) {
4786
- if (time === void 0) { time = now$1(); }
4761
+ if (time === void 0) { time = now(); }
4787
4762
  if (overrideStartingValues === void 0) { overrideStartingValues = false; }
4788
4763
  if (this._isPlaying) {
4789
4764
  return this;
@@ -4807,7 +4782,17 @@
4807
4782
  this._isChainStopped = false;
4808
4783
  this._startTime = time;
4809
4784
  this._startTime += this._delayTime;
4810
- this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4785
+ if (!this._propertiesAreSetUp || overrideStartingValues) {
4786
+ this._propertiesAreSetUp = true;
4787
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4788
+ if (!this._isDynamic) {
4789
+ var tmp = {};
4790
+ for (var prop in this._valuesEnd)
4791
+ tmp[prop] = this._valuesEnd[prop];
4792
+ this._valuesEnd = tmp;
4793
+ }
4794
+ this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
4795
+ }
4811
4796
  return this;
4812
4797
  };
4813
4798
  Tween.prototype.startFromCurrentValues = function (time) {
@@ -4830,26 +4815,42 @@
4830
4815
  if (endValues.length === 0) {
4831
4816
  continue;
4832
4817
  }
4833
- // handle an array of relative values
4834
- endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
4835
- // Create a local copy of the Array with the start value at the front
4836
- if (_valuesStart[property] === undefined) {
4837
- _valuesEnd[property] = [startValue].concat(endValues);
4818
+ // Handle an array of relative values.
4819
+ // Creates a local copy of the Array with the start value at the front
4820
+ var temp = [startValue];
4821
+ for (var i = 0, l = endValues.length; i < l; i += 1) {
4822
+ var value = this._handleRelativeValue(startValue, endValues[i]);
4823
+ if (isNaN(value)) {
4824
+ isInterpolationList = false;
4825
+ console.warn('Found invalid interpolation list. Skipping.');
4826
+ break;
4827
+ }
4828
+ temp.push(value);
4829
+ }
4830
+ if (isInterpolationList) {
4831
+ // if (_valuesStart[property] === undefined) { // handle end values only the first time. NOT NEEDED? setupProperties is now guarded by _propertiesAreSetUp.
4832
+ _valuesEnd[property] = temp;
4833
+ // }
4838
4834
  }
4839
4835
  }
4840
4836
  // handle the deepness of the values
4841
4837
  if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
4842
4838
  _valuesStart[property] = startValueIsArray ? [] : {};
4843
- // eslint-disable-next-line
4844
- for (var prop in startValue) {
4845
- // eslint-disable-next-line
4846
- // @ts-ignore FIXME?
4847
- _valuesStart[property][prop] = startValue[prop];
4839
+ var nestedObject = startValue;
4840
+ for (var prop in nestedObject) {
4841
+ _valuesStart[property][prop] = nestedObject[prop];
4848
4842
  }
4849
- _valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
4850
- // eslint-disable-next-line
4851
- // @ts-ignore FIXME?
4852
- this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
4843
+ // TODO? repeat nested values? And yoyo? And array values?
4844
+ _valuesStartRepeat[property] = startValueIsArray ? [] : {};
4845
+ var endValues = _valuesEnd[property];
4846
+ // If dynamic is not enabled, clone the end values instead of using the passed-in end values.
4847
+ if (!this._isDynamic) {
4848
+ var tmp = {};
4849
+ for (var prop in endValues)
4850
+ tmp[prop] = endValues[prop];
4851
+ _valuesEnd[property] = endValues = tmp;
4852
+ }
4853
+ this._setupProperties(nestedObject, _valuesStart[property], endValues, _valuesStartRepeat[property], overrideStartingValues);
4853
4854
  }
4854
4855
  else {
4855
4856
  // Save the starting value, but only once unless override is requested.
@@ -4895,7 +4896,7 @@
4895
4896
  return this;
4896
4897
  };
4897
4898
  Tween.prototype.pause = function (time) {
4898
- if (time === void 0) { time = now$1(); }
4899
+ if (time === void 0) { time = now(); }
4899
4900
  if (this._isPaused || !this._isPlaying) {
4900
4901
  return this;
4901
4902
  }
@@ -4906,7 +4907,7 @@
4906
4907
  return this;
4907
4908
  };
4908
4909
  Tween.prototype.resume = function (time) {
4909
- if (time === void 0) { time = now$1(); }
4910
+ if (time === void 0) { time = now(); }
4910
4911
  if (!this._isPaused || !this._isPlaying) {
4911
4912
  return this;
4912
4913
  }
@@ -4997,7 +4998,7 @@
4997
4998
  * it is still playing, just paused).
4998
4999
  */
4999
5000
  Tween.prototype.update = function (time, autoStart) {
5000
- if (time === void 0) { time = now$1(); }
5001
+ if (time === void 0) { time = now(); }
5001
5002
  if (autoStart === void 0) { autoStart = true; }
5002
5003
  if (this._isPaused)
5003
5004
  return true;
@@ -5120,9 +5121,7 @@
5120
5121
  if (end.charAt(0) === '+' || end.charAt(0) === '-') {
5121
5122
  return start + parseFloat(end);
5122
5123
  }
5123
- else {
5124
- return parseFloat(end);
5125
- }
5124
+ return parseFloat(end);
5126
5125
  };
5127
5126
  Tween.prototype._swapEndStartRepeatValues = function (property) {
5128
5127
  var tmp = this._valuesStartRepeat[property];
@@ -5137,18 +5136,6 @@
5137
5136
  };
5138
5137
  return Tween;
5139
5138
  }());
5140
-
5141
- var VERSION = '19.0.0';
5142
-
5143
- /**
5144
- * Tween.js - Licensed under the MIT license
5145
- * https://github.com/tweenjs/tween.js
5146
- * ----------------------------------------------
5147
- *
5148
- * See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
5149
- * Thank you all, you're awesome!
5150
- */
5151
- var nextId = Sequence.nextId;
5152
5139
  /**
5153
5140
  * Controlling groups of tweens
5154
5141
  *
@@ -5160,98 +5147,11 @@
5160
5147
  // Modules and CommonJS, without build hacks, and so as not to break the
5161
5148
  // existing API.
5162
5149
  // https://github.com/rollup/rollup/issues/1961#issuecomment-423037881
5163
- var getAll = TWEEN.getAll.bind(TWEEN);
5164
- var removeAll$3 = TWEEN.removeAll.bind(TWEEN);
5165
- var add$3 = TWEEN.add.bind(TWEEN);
5166
- var remove = TWEEN.remove.bind(TWEEN);
5150
+ TWEEN.getAll.bind(TWEEN);
5151
+ TWEEN.removeAll.bind(TWEEN);
5152
+ TWEEN.add.bind(TWEEN);
5153
+ TWEEN.remove.bind(TWEEN);
5167
5154
  var update = TWEEN.update.bind(TWEEN);
5168
- var exports$1 = {
5169
- Easing: Easing,
5170
- Group: Group,
5171
- Interpolation: Interpolation,
5172
- now: now$1,
5173
- Sequence: Sequence,
5174
- nextId: nextId,
5175
- Tween: Tween,
5176
- VERSION: VERSION,
5177
- getAll: getAll,
5178
- removeAll: removeAll$3,
5179
- add: add$3,
5180
- remove: remove,
5181
- update: update,
5182
- };
5183
-
5184
- var TWEEN$1 = exports$1;
5185
-
5186
- /**
5187
- * Returns a function, that, as long as it continues to be invoked, will not
5188
- * be triggered. The function will be called after it stops being called for
5189
- * N milliseconds. If `immediate` is passed, trigger the function on the
5190
- * leading edge, instead of the trailing. The function also has a property 'clear'
5191
- * that is a function which will clear the timer to prevent previously scheduled executions.
5192
- *
5193
- * @source underscore.js
5194
- * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
5195
- * @param {Function} function to wrap
5196
- * @param {Number} timeout in ms (`100`)
5197
- * @param {Boolean} whether to execute at the beginning (`false`)
5198
- * @api public
5199
- */
5200
-
5201
- function debounce(func, wait, immediate){
5202
- var timeout, args, context, timestamp, result;
5203
- if (null == wait) wait = 100;
5204
-
5205
- function later() {
5206
- var last = Date.now() - timestamp;
5207
-
5208
- if (last < wait && last >= 0) {
5209
- timeout = setTimeout(later, wait - last);
5210
- } else {
5211
- timeout = null;
5212
- if (!immediate) {
5213
- result = func.apply(context, args);
5214
- context = args = null;
5215
- }
5216
- }
5217
- }
5218
- var debounced = function(){
5219
- context = this;
5220
- args = arguments;
5221
- timestamp = Date.now();
5222
- var callNow = immediate && !timeout;
5223
- if (!timeout) timeout = setTimeout(later, wait);
5224
- if (callNow) {
5225
- result = func.apply(context, args);
5226
- context = args = null;
5227
- }
5228
-
5229
- return result;
5230
- };
5231
-
5232
- debounced.clear = function() {
5233
- if (timeout) {
5234
- clearTimeout(timeout);
5235
- timeout = null;
5236
- }
5237
- };
5238
-
5239
- debounced.flush = function() {
5240
- if (timeout) {
5241
- result = func.apply(context, args);
5242
- context = args = null;
5243
-
5244
- clearTimeout(timeout);
5245
- timeout = null;
5246
- }
5247
- };
5248
-
5249
- return debounced;
5250
- }
5251
- // Adds compatibility for ES modules
5252
- debounce.debounce = debounce;
5253
-
5254
- var debounce_1 = debounce;
5255
5155
 
5256
5156
  function _iterableToArrayLimit$1(arr, i) {
5257
5157
  var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
@@ -5393,7 +5293,7 @@
5393
5293
  initFn.call(comp, nodeElement, state, options);
5394
5294
  state.initialised = true;
5395
5295
  };
5396
- var digest = debounce_1(function () {
5296
+ var digest = debounce(function () {
5397
5297
  if (!state.initialised) {
5398
5298
  return;
5399
5299
  }
@@ -5469,7 +5369,7 @@
5469
5369
  }
5470
5370
 
5471
5371
  var index$2 = (function (p) {
5472
- return p instanceof Function ? p // fn
5372
+ return typeof p === 'function' ? p // fn
5473
5373
  : typeof p === 'string' ? function (obj) {
5474
5374
  return obj[p];
5475
5375
  } // property name
@@ -9568,6 +9468,7 @@
9568
9468
  This code is MIT licensed.
9569
9469
  **/
9570
9470
 
9471
+
9571
9472
  // math-inlining.
9572
9473
  const { abs, min, max, cos, sin, acos, sqrt } = Math;
9573
9474
  const pi = Math.PI;
@@ -11854,7 +11755,7 @@
11854
11755
  // no animation
11855
11756
  setCenter(finalPos);
11856
11757
  } else {
11857
- new TWEEN$1.Tween(getCenter()).to(finalPos, transitionDuration).easing(TWEEN$1.Easing.Quadratic.Out).onUpdate(setCenter).start();
11758
+ new Tween(getCenter()).to(finalPos, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(setCenter).start();
11858
11759
  }
11859
11760
  return this;
11860
11761
  }
@@ -11887,11 +11788,11 @@
11887
11788
  // no animation
11888
11789
  setZoom(k);
11889
11790
  } else {
11890
- new TWEEN$1.Tween({
11791
+ new Tween({
11891
11792
  k: getZoom()
11892
11793
  }).to({
11893
11794
  k: k
11894
- }, transitionDuration).easing(TWEEN$1.Easing.Quadratic.Out).onUpdate(function (_ref6) {
11795
+ }, transitionDuration).easing(Easing.Quadratic.Out).onUpdate(function (_ref6) {
11895
11796
  var k = _ref6.k;
11896
11797
  return setZoom(k);
11897
11798
  }).start();
@@ -12287,7 +12188,7 @@
12287
12188
  state.forceGraph.globalScale(globalScale).tickFrame();
12288
12189
  state.onRenderFramePost && state.onRenderFramePost(ctx, globalScale);
12289
12190
  }
12290
- TWEEN$1.update(); // update canvas animation tweens
12191
+ update(); // update canvas animation tweens
12291
12192
 
12292
12193
  state.animationFrameRequestId = requestAnimationFrame(animate);
12293
12194
  })();