@antv/l7-map 2.17.12 → 2.18.0

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.
Files changed (104) hide show
  1. package/es/camera.js +92 -149
  2. package/es/earthmap.js +15 -68
  3. package/es/geo/edge_insets.js +4 -14
  4. package/es/geo/lng_lat.js +5 -13
  5. package/es/geo/lng_lat_bounds.js +4 -17
  6. package/es/geo/mercator.js +2 -10
  7. package/es/geo/point.js +0 -7
  8. package/es/geo/simple.js +6 -11
  9. package/es/geo/transform.js +128 -138
  10. package/es/handler/blockable_map_event.js +7 -12
  11. package/es/handler/box_zoom.js +10 -30
  12. package/es/handler/click_zoom.js +0 -5
  13. package/es/handler/events/event.js +2 -3
  14. package/es/handler/events/map_mouse_event.js +2 -13
  15. package/es/handler/events/map_touch_event.js +2 -12
  16. package/es/handler/events/map_wheel_event.js +1 -12
  17. package/es/handler/events/render_event.js +0 -13
  18. package/es/handler/handler_inertia.js +8 -35
  19. package/es/handler/handler_manager.js +90 -197
  20. package/es/handler/handler_util.js +1 -2
  21. package/es/handler/keyboard.js +1 -20
  22. package/es/handler/map_event.js +3 -9
  23. package/es/handler/mouse/mouse_handler.js +11 -24
  24. package/es/handler/mouse/mousepan_handler.js +1 -11
  25. package/es/handler/mouse/mousepitch_hander.js +1 -11
  26. package/es/handler/mouse/mouserotate_hander.js +1 -11
  27. package/es/handler/mouse/util.js +2 -3
  28. package/es/handler/scroll_zoom.js +43 -71
  29. package/es/handler/shim/dblclick_zoom.js +4 -9
  30. package/es/handler/shim/drag_pan.js +6 -18
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +8 -23
  33. package/es/handler/tap/single_tap_recognizer.js +8 -31
  34. package/es/handler/tap/tap_drag_zoom.js +7 -15
  35. package/es/handler/tap/tap_recognizer.js +3 -11
  36. package/es/handler/tap/tap_zoom.js +1 -7
  37. package/es/handler/touch/touch_pan.js +4 -22
  38. package/es/handler/touch/touch_pitch.js +10 -27
  39. package/es/handler/touch/touch_rotate.js +8 -19
  40. package/es/handler/touch/touch_zoom.js +5 -18
  41. package/es/handler/touch/two_touch.js +19 -32
  42. package/es/hash.js +13 -35
  43. package/es/map.js +30 -107
  44. package/es/util.d.ts +3 -3
  45. package/es/util.js +20 -33
  46. package/es/utils/Aabb.js +10 -31
  47. package/es/utils/dom.js +33 -111
  48. package/es/utils/performance.js +9 -9
  49. package/es/utils/primitives.js +13 -11
  50. package/es/utils/task_queue.js +6 -23
  51. package/lib/camera.js +102 -179
  52. package/lib/earthmap.js +14 -83
  53. package/lib/geo/edge_insets.js +3 -18
  54. package/lib/geo/lng_lat.js +5 -18
  55. package/lib/geo/lng_lat_bounds.js +4 -20
  56. package/lib/geo/mercator.js +1 -22
  57. package/lib/geo/point.js +0 -8
  58. package/lib/geo/simple.js +5 -24
  59. package/lib/geo/transform.js +128 -170
  60. package/lib/handler/blockable_map_event.js +6 -14
  61. package/lib/handler/box_zoom.js +8 -39
  62. package/lib/handler/click_zoom.js +0 -6
  63. package/lib/handler/events/event.js +4 -7
  64. package/lib/handler/events/index.js +0 -4
  65. package/lib/handler/events/map_mouse_event.js +5 -22
  66. package/lib/handler/events/map_touch_event.js +2 -21
  67. package/lib/handler/events/map_wheel_event.js +1 -16
  68. package/lib/handler/events/render_event.js +0 -19
  69. package/lib/handler/handler_inertia.js +13 -44
  70. package/lib/handler/handler_manager.js +92 -222
  71. package/lib/handler/handler_util.js +1 -3
  72. package/lib/handler/keyboard.js +1 -22
  73. package/lib/handler/map_event.js +2 -11
  74. package/lib/handler/mouse/index.js +0 -4
  75. package/lib/handler/mouse/mouse_handler.js +10 -27
  76. package/lib/handler/mouse/mousepan_handler.js +1 -18
  77. package/lib/handler/mouse/mousepitch_hander.js +1 -17
  78. package/lib/handler/mouse/mouserotate_hander.js +1 -17
  79. package/lib/handler/mouse/util.js +2 -6
  80. package/lib/handler/scroll_zoom.js +43 -77
  81. package/lib/handler/shim/dblclick_zoom.js +4 -10
  82. package/lib/handler/shim/drag_pan.js +6 -20
  83. package/lib/handler/shim/drag_rotate.js +4 -11
  84. package/lib/handler/shim/touch_zoom_rotate.js +8 -25
  85. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  86. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  87. package/lib/handler/tap/tap_recognizer.js +2 -17
  88. package/lib/handler/tap/tap_zoom.js +0 -9
  89. package/lib/handler/touch/index.js +0 -5
  90. package/lib/handler/touch/touch_pan.js +4 -25
  91. package/lib/handler/touch/touch_pitch.js +10 -32
  92. package/lib/handler/touch/touch_rotate.js +8 -25
  93. package/lib/handler/touch/touch_zoom.js +5 -24
  94. package/lib/handler/touch/two_touch.js +18 -35
  95. package/lib/hash.js +12 -38
  96. package/lib/index.js +0 -8
  97. package/lib/map.js +30 -125
  98. package/lib/util.js +19 -46
  99. package/lib/utils/Aabb.js +10 -34
  100. package/lib/utils/dom.js +32 -118
  101. package/lib/utils/performance.js +9 -11
  102. package/lib/utils/primitives.js +13 -16
  103. package/lib/utils/task_queue.js +6 -24
  104. package/package.json +4 -4
package/es/utils/dom.js CHANGED
@@ -1,48 +1,34 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
-
3
2
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
-
5
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
-
7
- import { $window, isMini } from '@antv/l7-utils'; // @ts-ignore
8
-
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ // @ts-ignore
9
5
  import Point from "../geo/point";
10
6
  var DOM = {};
11
7
  export default DOM;
12
-
13
8
  DOM.create = function (tagName, className, container) {
14
- var el = $window.document.createElement(tagName);
15
-
9
+ var el = window.document.createElement(tagName);
16
10
  if (className !== undefined) {
17
11
  el.className = className;
18
12
  }
19
-
20
13
  if (container) {
21
14
  container.appendChild(el);
22
15
  }
23
-
24
16
  return el;
25
17
  };
26
-
27
18
  DOM.createNS = function (namespaceURI, tagName) {
28
- var el = $window.document.createElementNS(namespaceURI, tagName);
19
+ var el = window.document.createElementNS(namespaceURI, tagName);
29
20
  return el;
30
21
  };
31
-
32
- var docStyle = $window.document && $window.document.documentElement.style;
33
-
22
+ var docStyle = window.document && window.document.documentElement.style;
34
23
  function testProp(props) {
35
24
  if (!docStyle) {
36
25
  return props[0];
37
26
  }
38
-
39
27
  var _iterator = _createForOfIteratorHelper(props),
40
- _step;
41
-
28
+ _step;
42
29
  try {
43
30
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
31
  var i = _step.value;
45
-
46
32
  if (i in docStyle) {
47
33
  return i;
48
34
  }
@@ -52,37 +38,30 @@ function testProp(props) {
52
38
  } finally {
53
39
  _iterator.f();
54
40
  }
55
-
56
41
  return props[0];
57
42
  }
58
-
59
43
  var selectProp = testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);
60
44
  var userSelect;
61
-
62
45
  DOM.disableDrag = function () {
63
46
  if (docStyle && selectProp) {
64
47
  userSelect = docStyle[selectProp];
65
48
  docStyle[selectProp] = 'none';
66
49
  }
67
50
  };
68
-
69
51
  DOM.enableDrag = function () {
70
52
  if (docStyle && selectProp) {
71
53
  docStyle[selectProp] = userSelect;
72
54
  }
73
55
  };
74
-
75
56
  var transformProp = testProp(['transform', 'WebkitTransform']);
76
-
77
57
  DOM.setTransform = function (el, value) {
78
58
  // https://github.com/facebook/flow/issues/7754
79
59
  // $FlowFixMe
80
60
  el.style[transformProp] = value;
81
- }; // Feature detection for {passive: false} support in add/removeEventListener.
82
-
61
+ };
83
62
 
63
+ // Feature detection for {passive: false} support in add/removeEventListener.
84
64
  var passiveSupported = false;
85
-
86
65
  try {
87
66
  // https://github.com/facebook/flow/issues/285
88
67
  // $FlowFixMe
@@ -91,126 +70,69 @@ try {
91
70
  // eslint-disable-line
92
71
  passiveSupported = true;
93
72
  }
94
- }); // @ts-ignore
95
-
96
- $window.addEventListener('test', options, options); // @ts-ignore
97
-
98
- $window.removeEventListener('test', options, options);
73
+ });
74
+ // @ts-ignore
75
+ window.addEventListener('test', options, options);
76
+ // @ts-ignore
77
+ window.removeEventListener('test', options, options);
99
78
  } catch (err) {
100
79
  passiveSupported = false;
101
80
  }
102
-
103
81
  DOM.addEventListener = function (target, type, callback) {
104
82
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
105
-
106
83
  if ('passive' in options && passiveSupported) {
107
84
  target.addEventListener(type, callback, options);
108
85
  } else {
109
86
  target.addEventListener(type, callback, options.capture);
110
87
  }
111
88
  };
112
-
113
89
  DOM.removeEventListener = function (target, type, callback) {
114
90
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
115
-
116
91
  if ('passive' in options && passiveSupported) {
117
92
  target.removeEventListener(type, callback, options);
118
93
  } else {
119
94
  target.removeEventListener(type, callback, options.capture);
120
95
  }
121
- }; // Suppress the next click, but only if it's immediate.
122
-
96
+ };
123
97
 
98
+ // Suppress the next click, but only if it's immediate.
124
99
  var suppressClick = function suppressClick(e) {
125
100
  e.preventDefault();
126
101
  e.stopPropagation();
127
- $window.removeEventListener('click', suppressClick, true);
102
+ window.removeEventListener('click', suppressClick, true);
128
103
  };
129
-
130
104
  DOM.suppressClick = function () {
131
- if (isMini) {
132
- return;
133
- }
134
-
135
- $window.addEventListener('click', suppressClick, true);
105
+ window.addEventListener('click', suppressClick, true);
136
106
  setTimeout(function () {
137
- $window.removeEventListener('click', suppressClick, true);
107
+ window.removeEventListener('click', suppressClick, true);
138
108
  }, 0);
139
109
  };
140
-
141
110
  DOM.mousePos = function (el, e) {
142
111
  // 暂时从 el 上获取 top/left, 后面需要动态获取
143
- if (!isMini) {
144
- var rect = el.getBoundingClientRect();
145
- return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
146
- } else {
147
- return new Point( // @ts-ignore
148
- e.clientX - el.left - 0, // @ts-ignore
149
- e.clientY - el.top - 0);
150
- }
112
+ var rect = el.getBoundingClientRect();
113
+ return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
151
114
  };
152
-
153
115
  DOM.touchPos = function (el, touches) {
154
116
  // 暂时从 el 上获取 top/left, 后面需要动态获取
155
- if (!isMini) {
156
- var rect = el.getBoundingClientRect();
157
- var points = [];
158
-
159
- var _iterator2 = _createForOfIteratorHelper(touches),
160
- _step2;
161
-
162
- try {
163
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
164
- var touche = _step2.value;
165
- points.push(new Point(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
166
- }
167
- } catch (err) {
168
- _iterator2.e(err);
169
- } finally {
170
- _iterator2.f();
171
- }
172
-
173
- return points;
174
- } else {
175
- var _points = [];
176
-
177
- var _iterator3 = _createForOfIteratorHelper(touches),
178
- _step3;
179
-
180
- try {
181
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
182
- var _touche = _step3.value;
183
-
184
- _points.push(new Point( // @ts-ignore
185
- _touche.clientX - el.left, // @ts-ignore
186
- _touche.clientY - el.top));
187
- }
188
- } catch (err) {
189
- _iterator3.e(err);
190
- } finally {
191
- _iterator3.f();
117
+ var rect = el.getBoundingClientRect();
118
+ var points = [];
119
+ var _iterator2 = _createForOfIteratorHelper(touches),
120
+ _step2;
121
+ try {
122
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
123
+ var touche = _step2.value;
124
+ points.push(new Point(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
192
125
  }
193
-
194
- return _points;
126
+ } catch (err) {
127
+ _iterator2.e(err);
128
+ } finally {
129
+ _iterator2.f();
195
130
  }
131
+ return points;
196
132
  };
197
-
198
133
  DOM.mouseButton = function (e) {
199
- if (!isMini) {
200
- return e.button;
201
- }
202
-
203
- if ( // @ts-ignore
204
- typeof $window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
205
- // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
206
- // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
207
- // using Control + left click
208
- return 0;
209
- }
210
-
211
134
  return e.button;
212
135
  };
213
-
214
136
  DOM.remove = function (node) {
215
137
  if (node.parentNode) {
216
138
  node.parentNode.removeChild(node);
@@ -1,9 +1,8 @@
1
- import { $window } from '@antv/l7-utils';
2
1
  var lastFrameTime = null;
3
2
  var frameTimes = [];
4
3
  var minFramerateTarget = 30;
5
4
  var frameTimeTarget = 1000 / minFramerateTarget;
6
- var performance = $window.performance;
5
+ var performance = window.performance;
7
6
  export var PerformanceMarkers = {
8
7
  create: 'create',
9
8
  load: 'load',
@@ -15,37 +14,38 @@ export var PerformanceUtils = {
15
14
  },
16
15
  frame: function frame(timestamp) {
17
16
  var currTimestamp = timestamp;
18
-
19
17
  if (lastFrameTime != null) {
20
18
  var frameTime = currTimestamp - lastFrameTime;
21
19
  frameTimes.push(frameTime);
22
20
  }
23
-
24
21
  lastFrameTime = currTimestamp;
25
22
  },
26
23
  clearMetrics: function clearMetrics() {
27
24
  lastFrameTime = null;
28
25
  frameTimes = [];
29
26
  performance.clearMeasures('loadTime');
30
- performance.clearMeasures('fullLoadTime'); // @ts-ignore
27
+ performance.clearMeasures('fullLoadTime');
28
+ // @ts-ignore
31
29
  // tslint:disable-next-line:forin
32
-
33
30
  for (var marker in PerformanceMarkers) {
34
31
  // @ts-ignore
35
32
  performance.clearMarks(PerformanceMarkers[marker]);
36
33
  }
37
34
  },
38
35
  getPerformanceMetrics: function getPerformanceMetrics() {
39
- var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load // @ts-ignore
36
+ var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load
37
+ // @ts-ignore
40
38
  ).duration;
41
- var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad // @ts-ignore
39
+ var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad
40
+ // @ts-ignore
42
41
  ).duration;
43
42
  var totalFrames = frameTimes.length;
44
43
  var avgFrameTime = frameTimes.reduce(function (prev, curr) {
45
44
  return prev + curr;
46
45
  }, 0) / totalFrames / 1000;
47
- var fps = 1 / avgFrameTime; // count frames that missed our framerate target
46
+ var fps = 1 / avgFrameTime;
48
47
 
48
+ // count frames that missed our framerate target
49
49
  var droppedFrames = frameTimes.filter(function (frameTime) {
50
50
  return frameTime > frameTimeTarget;
51
51
  }).reduce(function (acc, curr) {
@@ -1,33 +1,37 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import { vec3, vec4 } from 'gl-matrix';
4
-
5
4
  var Frustum = /*#__PURE__*/function () {
6
5
  function Frustum(points, planes) {
7
6
  _classCallCheck(this, Frustum);
8
-
9
7
  this.points = points;
10
8
  this.planes = planes;
11
9
  }
12
-
13
10
  _createClass(Frustum, null, [{
14
11
  key: "fromInvProjectionMatrix",
15
12
  value: function fromInvProjectionMatrix(invProj, worldSize, zoom) {
16
13
  var clipSpaceCorners = [[-1, 1, -1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [-1, -1, -1, 1], [-1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1], [-1, -1, 1, 1]];
17
- var scale = Math.pow(2, zoom); // Transform frustum corner points from clip space to tile space
14
+ var scale = Math.pow(2, zoom);
18
15
 
16
+ // Transform frustum corner points from clip space to tile space
19
17
  var frustumCoords = clipSpaceCorners.map(function (v) {
20
18
  return vec4.transformMat4(new Float32Array([]), v, invProj);
21
19
  }).map(function (v) {
22
20
  return vec4.scale(new Float32Array([]), v, 1.0 / v[3] / worldSize * scale);
23
21
  });
24
- var frustumPlanePointIndices = [[0, 1, 2], // near
25
- [6, 5, 4], // far
26
- [0, 3, 7], // left
27
- [2, 1, 5], // right
28
- [3, 2, 6], // bottom
22
+ var frustumPlanePointIndices = [[0, 1, 2],
23
+ // near
24
+ [6, 5, 4],
25
+ // far
26
+ [0, 3, 7],
27
+ // left
28
+ [2, 1, 5],
29
+ // right
30
+ [3, 2, 6],
31
+ // bottom
29
32
  [0, 4, 5] // top
30
33
  ];
34
+
31
35
  var frustumPlanes = frustumPlanePointIndices.map(function (p) {
32
36
  var a = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[0]]), new Float32Array(frustumCoords[p[1]]));
33
37
  var b = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[2]]), new Float32Array(frustumCoords[p[1]]));
@@ -38,8 +42,6 @@ var Frustum = /*#__PURE__*/function () {
38
42
  return new Frustum(frustumCoords, frustumPlanes);
39
43
  }
40
44
  }]);
41
-
42
45
  return Frustum;
43
46
  }();
44
-
45
47
  export { Frustum as default };
@@ -1,23 +1,17 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
-
4
3
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
-
6
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
-
8
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
9
-
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
6
  // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61
11
7
  var TaskQueue = /*#__PURE__*/function () {
12
8
  function TaskQueue() {
13
9
  _classCallCheck(this, TaskQueue);
14
-
15
10
  this.queue = [];
16
11
  this.id = 0;
17
12
  this.cleared = false;
18
13
  this.currentlyRunning = false;
19
14
  }
20
-
21
15
  _createClass(TaskQueue, [{
22
16
  key: "add",
23
17
  value: function add(callback) {
@@ -35,14 +29,11 @@ var TaskQueue = /*#__PURE__*/function () {
35
29
  value: function remove(id) {
36
30
  var running = this.currentlyRunning;
37
31
  var queue = running ? this.queue.concat(running) : this.queue;
38
-
39
32
  var _iterator = _createForOfIteratorHelper(queue),
40
- _step;
41
-
33
+ _step;
42
34
  try {
43
35
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
36
  var task = _step.value;
45
-
46
37
  if (task.id === id) {
47
38
  task.cancelled = true;
48
39
  return;
@@ -58,24 +49,20 @@ var TaskQueue = /*#__PURE__*/function () {
58
49
  key: "run",
59
50
  value: function run() {
60
51
  var timeStamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
61
- var queue = this.currentlyRunning = this.queue; // Tasks queued by callbacks in the current queue should be executed
62
- // on the next run, not the current run.
52
+ var queue = this.currentlyRunning = this.queue;
63
53
 
54
+ // Tasks queued by callbacks in the current queue should be executed
55
+ // on the next run, not the current run.
64
56
  this.queue = [];
65
-
66
57
  var _iterator2 = _createForOfIteratorHelper(queue),
67
- _step2;
68
-
58
+ _step2;
69
59
  try {
70
60
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
71
61
  var task = _step2.value;
72
-
73
62
  if (task.cancelled) {
74
63
  continue;
75
64
  }
76
-
77
65
  task.callback(timeStamp);
78
-
79
66
  if (this.cleared) {
80
67
  break;
81
68
  }
@@ -85,7 +72,6 @@ var TaskQueue = /*#__PURE__*/function () {
85
72
  } finally {
86
73
  _iterator2.f();
87
74
  }
88
-
89
75
  this.cleared = false;
90
76
  this.currentlyRunning = false;
91
77
  }
@@ -95,12 +81,9 @@ var TaskQueue = /*#__PURE__*/function () {
95
81
  if (this.currentlyRunning) {
96
82
  this.cleared = true;
97
83
  }
98
-
99
84
  this.queue = [];
100
85
  }
101
86
  }]);
102
-
103
87
  return TaskQueue;
104
88
  }();
105
-
106
89
  export default TaskQueue;