@lowentry/utils 1.24.1 → 1.24.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.
package/index.js CHANGED
@@ -1867,7 +1867,6 @@ var LeUtils = {
1867
1867
  * @returns {{remove:Function}}
1868
1868
  */
1869
1869
  setAnimationFrameInterval: function setAnimationFrameInterval(callback) {
1870
- var _globalThis$performan17, _globalThis$performan18, _globalThis$performan19;
1871
1870
  var intervalFrames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1872
1871
  var fireImmediately = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1873
1872
  intervalFrames = INT_LAX_ANY(intervalFrames, 1);
@@ -1886,22 +1885,26 @@ var LeUtils = {
1886
1885
  }
1887
1886
  var run = true;
1888
1887
  var requestAnimationFrameId = null;
1889
- var lastTime = (_globalThis$performan17 = globalThis === null || globalThis === void 0 || (_globalThis$performan18 = globalThis.performance) === null || _globalThis$performan18 === void 0 || (_globalThis$performan19 = _globalThis$performan18.now) === null || _globalThis$performan19 === void 0 ? void 0 : _globalThis$performan19.call(_globalThis$performan18)) !== null && _globalThis$performan17 !== void 0 ? _globalThis$performan17 : 0;
1888
+ var lastTimestamp = 0;
1889
+ var totalTime = 0;
1890
1890
  var frames = intervalFrames;
1891
- var _tick2 = function tick() {
1891
+ var _tick2 = function tick(timestamp) {
1892
1892
  if (run) {
1893
+ if (lastTimestamp === 0) {
1894
+ lastTimestamp = timestamp;
1895
+ }
1896
+ totalTime += timestamp - lastTimestamp;
1897
+ lastTimestamp = timestamp;
1898
+ frames--;
1893
1899
  if (frames <= 0) {
1894
- var _globalThis$performan20, _globalThis$performan21, _globalThis$performan22;
1895
- var currentTime = (_globalThis$performan20 = globalThis === null || globalThis === void 0 || (_globalThis$performan21 = globalThis.performance) === null || _globalThis$performan21 === void 0 || (_globalThis$performan22 = _globalThis$performan21.now) === null || _globalThis$performan22 === void 0 ? void 0 : _globalThis$performan22.call(_globalThis$performan21)) !== null && _globalThis$performan20 !== void 0 ? _globalThis$performan20 : 0;
1896
1900
  try {
1897
- callback((currentTime - lastTime) / 1000);
1901
+ callback(totalTime / 1000);
1898
1902
  } catch (e) {
1899
1903
  console.error(e);
1900
1904
  }
1901
- lastTime = currentTime;
1905
+ totalTime = 0;
1902
1906
  frames = intervalFrames;
1903
1907
  }
1904
- frames--;
1905
1908
  if (run) {
1906
1909
  requestAnimationFrameId = globalThis.requestAnimationFrame(_tick2);
1907
1910
  }
@@ -2478,9 +2481,9 @@ var LeUtils = {
2478
2481
  var generateUniqueId = function generateUniqueId() {
2479
2482
  var now;
2480
2483
  try {
2481
- var _globalThis$performan23, _globalThis$performan24, _globalThis$performan25, _globalThis$performan26, _globalThis$performan27;
2484
+ var _globalThis$performan17, _globalThis$performan18, _globalThis$performan19, _globalThis$performan20, _globalThis$performan21;
2482
2485
  // noinspection JSDeprecatedSymbols
2483
- now = ((globalThis === null || globalThis === void 0 || (_globalThis$performan23 = globalThis.performance) === null || _globalThis$performan23 === void 0 ? void 0 : _globalThis$performan23.timeOrigin) || (globalThis === null || globalThis === void 0 || (_globalThis$performan24 = globalThis.performance) === null || _globalThis$performan24 === void 0 || (_globalThis$performan24 = _globalThis$performan24.timing) === null || _globalThis$performan24 === void 0 ? void 0 : _globalThis$performan24.navigationStart) || 0) + ((_globalThis$performan25 = globalThis === null || globalThis === void 0 || (_globalThis$performan26 = globalThis.performance) === null || _globalThis$performan26 === void 0 || (_globalThis$performan27 = _globalThis$performan26.now) === null || _globalThis$performan27 === void 0 ? void 0 : _globalThis$performan27.call(_globalThis$performan26)) !== null && _globalThis$performan25 !== void 0 ? _globalThis$performan25 : 0);
2486
+ now = ((globalThis === null || globalThis === void 0 || (_globalThis$performan17 = globalThis.performance) === null || _globalThis$performan17 === void 0 ? void 0 : _globalThis$performan17.timeOrigin) || (globalThis === null || globalThis === void 0 || (_globalThis$performan18 = globalThis.performance) === null || _globalThis$performan18 === void 0 || (_globalThis$performan18 = _globalThis$performan18.timing) === null || _globalThis$performan18 === void 0 ? void 0 : _globalThis$performan18.navigationStart) || 0) + ((_globalThis$performan19 = globalThis === null || globalThis === void 0 || (_globalThis$performan20 = globalThis.performance) === null || _globalThis$performan20 === void 0 || (_globalThis$performan21 = _globalThis$performan20.now) === null || _globalThis$performan21 === void 0 ? void 0 : _globalThis$performan21.call(_globalThis$performan20)) !== null && _globalThis$performan19 !== void 0 ? _globalThis$performan19 : 0);
2484
2487
  } catch (e) {}
2485
2488
  now = now || (Date.now ? Date.now() : new Date().getTime());
2486
2489
  now = Math.round(now);