@antv/l7-map 2.17.10 → 2.17.12

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