@antv/l7-map 2.17.4 → 2.17.6

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 +90 -148
  2. package/es/earthmap.js +13 -65
  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 +123 -132
  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 +0 -2
  14. package/es/handler/events/map_mouse_event.js +0 -12
  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 +6 -34
  19. package/es/handler/handler_manager.js +55 -147
  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 +4 -11
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +6 -16
  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 +9 -31
  43. package/es/map.js +16 -78
  44. package/es/util.js +18 -26
  45. package/es/utils/Aabb.js +10 -31
  46. package/es/utils/dom.js +24 -58
  47. package/es/utils/performance.js +8 -7
  48. package/es/utils/primitives.js +13 -11
  49. package/es/utils/task_queue.js +6 -23
  50. package/lib/camera.js +90 -168
  51. package/lib/earthmap.js +11 -79
  52. package/lib/geo/edge_insets.js +3 -18
  53. package/lib/geo/lng_lat.js +5 -18
  54. package/lib/geo/lng_lat_bounds.js +4 -20
  55. package/lib/geo/mercator.js +1 -22
  56. package/lib/geo/point.js +0 -8
  57. package/lib/geo/simple.js +5 -24
  58. package/lib/geo/transform.js +123 -164
  59. package/lib/handler/blockable_map_event.js +6 -14
  60. package/lib/handler/box_zoom.js +8 -39
  61. package/lib/handler/click_zoom.js +0 -6
  62. package/lib/handler/events/event.js +0 -5
  63. package/lib/handler/events/index.js +0 -4
  64. package/lib/handler/events/map_mouse_event.js +0 -19
  65. package/lib/handler/events/map_touch_event.js +1 -20
  66. package/lib/handler/events/map_wheel_event.js +1 -16
  67. package/lib/handler/events/render_event.js +0 -19
  68. package/lib/handler/handler_inertia.js +4 -37
  69. package/lib/handler/handler_manager.js +55 -171
  70. package/lib/handler/handler_util.js +1 -3
  71. package/lib/handler/keyboard.js +1 -22
  72. package/lib/handler/map_event.js +2 -11
  73. package/lib/handler/mouse/index.js +0 -4
  74. package/lib/handler/mouse/mouse_handler.js +10 -27
  75. package/lib/handler/mouse/mousepan_handler.js +0 -17
  76. package/lib/handler/mouse/mousepitch_hander.js +0 -16
  77. package/lib/handler/mouse/mouserotate_hander.js +0 -16
  78. package/lib/handler/mouse/util.js +2 -6
  79. package/lib/handler/scroll_zoom.js +43 -77
  80. package/lib/handler/shim/dblclick_zoom.js +4 -10
  81. package/lib/handler/shim/drag_pan.js +4 -13
  82. package/lib/handler/shim/drag_rotate.js +4 -11
  83. package/lib/handler/shim/touch_zoom_rotate.js +6 -18
  84. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  85. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  86. package/lib/handler/tap/tap_recognizer.js +2 -17
  87. package/lib/handler/tap/tap_zoom.js +0 -9
  88. package/lib/handler/touch/index.js +0 -5
  89. package/lib/handler/touch/touch_pan.js +4 -25
  90. package/lib/handler/touch/touch_pitch.js +9 -31
  91. package/lib/handler/touch/touch_rotate.js +7 -24
  92. package/lib/handler/touch/touch_zoom.js +4 -23
  93. package/lib/handler/touch/two_touch.js +18 -35
  94. package/lib/hash.js +8 -35
  95. package/lib/index.js +0 -8
  96. package/lib/map.js +14 -94
  97. package/lib/util.js +16 -38
  98. package/lib/utils/Aabb.js +10 -34
  99. package/lib/utils/dom.js +22 -64
  100. package/lib/utils/performance.js +8 -9
  101. package/lib/utils/primitives.js +13 -16
  102. package/lib/utils/task_queue.js +6 -24
  103. package/package.json +3 -3
package/es/util.js CHANGED
@@ -1,11 +1,8 @@
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
+ import { $window, isMini } from '@antv/l7-utils';
5
+ // @ts-ignore
9
6
  import UnitBezier from '@mapbox/unitbezier';
10
7
  var reducedMotionQuery;
11
8
  export function wrap(n, min, max) {
@@ -30,26 +27,21 @@ export function prefersReducedMotion() {
30
27
  // @ts-ignore
31
28
  if (isMini || !$window.matchMedia) {
32
29
  return false;
33
- } // Lazily initialize media query
34
-
35
-
30
+ }
31
+ // Lazily initialize media query
36
32
  if (reducedMotionQuery == null) {
37
33
  // @ts-ignore
38
34
  reducedMotionQuery = $window.matchMedia('(prefers-reduced-motion: reduce)');
39
35
  }
40
-
41
36
  return reducedMotionQuery.matches;
42
37
  }
43
38
  export function pick(src, properties) {
44
39
  var result = {};
45
-
46
40
  var _iterator = _createForOfIteratorHelper(properties),
47
- _step;
48
-
41
+ _step;
49
42
  try {
50
43
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
51
44
  var name = _step.value;
52
-
53
45
  if (name in src) {
54
46
  result[name] = src[name];
55
47
  }
@@ -59,20 +51,23 @@ export function pick(src, properties) {
59
51
  } finally {
60
52
  _iterator.f();
61
53
  }
62
-
63
54
  return result;
64
55
  }
65
56
  export var now = isMini ? Date.now.bind(Date) : $window.performance && $window.performance.now ? $window.performance.now.bind($window.performance) : Date.now.bind(Date);
66
- export var raf = $window.requestAnimationFrame || // @ts-ignore
67
- $window.mozRequestAnimationFrame || // @ts-ignore
68
- $window.webkitRequestAnimationFrame || // @ts-ignore
57
+ export var raf = $window.requestAnimationFrame ||
58
+ // @ts-ignore
59
+ $window.mozRequestAnimationFrame ||
60
+ // @ts-ignore
61
+ $window.webkitRequestAnimationFrame ||
62
+ // @ts-ignore
69
63
  $window.msRequestAnimationFrame;
70
-
71
- var _cancel = $window.cancelAnimationFrame || // @ts-ignore
72
- $window.mozCancelAnimationFrame || // @ts-ignore
73
- $window.webkitCancelAnimationFrame || // @ts-ignore
64
+ var _cancel = $window.cancelAnimationFrame ||
65
+ // @ts-ignore
66
+ $window.mozCancelAnimationFrame ||
67
+ // @ts-ignore
68
+ $window.webkitCancelAnimationFrame ||
69
+ // @ts-ignore
74
70
  $window.msCancelAnimationFrame;
75
-
76
71
  export { _cancel as cancel };
77
72
  export function renderframe(fn) {
78
73
  var frame = raf(fn);
@@ -86,16 +81,13 @@ export function extend(dest) {
86
81
  for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
87
82
  sources[_key - 1] = arguments[_key];
88
83
  }
89
-
90
84
  for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
91
85
  var src = _sources[_i];
92
-
93
86
  for (var k in src) {
94
87
  if (src[k] !== undefined) {
95
88
  dest[k] = src[k];
96
89
  }
97
90
  }
98
91
  }
99
-
100
92
  return dest;
101
93
  }
package/es/utils/Aabb.js CHANGED
@@ -1,36 +1,27 @@
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
  import { vec3, vec4 } from 'gl-matrix';
11
-
12
7
  var Aabb = /*#__PURE__*/function () {
13
8
  function Aabb(min, max) {
14
9
  _classCallCheck(this, Aabb);
15
-
16
10
  this.min = min;
17
11
  this.max = max;
18
12
  this.center = vec3.scale(new Float32Array(3), vec3.add(new Float32Array(3), this.min, this.max), 0.5);
19
13
  }
20
-
21
14
  _createClass(Aabb, [{
22
15
  key: "quadrant",
23
16
  value: function quadrant(index) {
24
17
  var split = [index % 2 === 0, index < 2];
25
18
  var qMin = vec3.clone(this.min);
26
19
  var qMax = vec3.clone(this.max);
27
-
28
20
  for (var axis = 0; axis < split.length; axis++) {
29
21
  qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
30
22
  qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
31
- } // Elevation is always constant, hence quadrant.max.z = this.max.z
32
-
33
-
23
+ }
24
+ // Elevation is always constant, hence quadrant.max.z = this.max.z
34
25
  qMax[2] = this.max[2];
35
26
  return new Aabb(qMin, qMax);
36
27
  }
@@ -45,29 +36,27 @@ var Aabb = /*#__PURE__*/function () {
45
36
  value: function distanceY(point) {
46
37
  var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
47
38
  return pointOnAabb - point[1];
48
- } // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
49
- // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
39
+ }
50
40
 
41
+ // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
42
+ // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
51
43
  }, {
52
44
  key: "intersects",
53
45
  value: function intersects(frustum) {
54
46
  // Execute separating axis test between two convex objects to find intersections
55
47
  // Each frustum plane together with 3 major axes define the separating axes
56
48
  // Note: test only 4 points as both min and max points have equal elevation
49
+
57
50
  var aabbPoints = [[this.min[0], this.min[1], 0.0, 1], [this.max[0], this.min[1], 0.0, 1], [this.max[0], this.max[1], 0.0, 1], [this.min[0], this.max[1], 0.0, 1]];
58
51
  var fullyInside = true;
59
-
60
52
  var _iterator = _createForOfIteratorHelper(frustum.planes),
61
- _step;
62
-
53
+ _step;
63
54
  try {
64
55
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
56
  var plane = _step.value;
66
57
  var pointsInside = 0;
67
-
68
58
  var _iterator3 = _createForOfIteratorHelper(aabbPoints),
69
- _step3;
70
-
59
+ _step3;
71
60
  try {
72
61
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
73
62
  var i = _step3.value;
@@ -79,11 +68,9 @@ var Aabb = /*#__PURE__*/function () {
79
68
  } finally {
80
69
  _iterator3.f();
81
70
  }
82
-
83
71
  if (pointsInside === 0) {
84
72
  return 0;
85
73
  }
86
-
87
74
  if (pointsInside !== aabbPoints.length) {
88
75
  fullyInside = false;
89
76
  }
@@ -93,18 +80,14 @@ var Aabb = /*#__PURE__*/function () {
93
80
  } finally {
94
81
  _iterator.f();
95
82
  }
96
-
97
83
  if (fullyInside) {
98
84
  return 2;
99
85
  }
100
-
101
86
  for (var axis = 0; axis < 3; axis++) {
102
87
  var projMin = Number.MAX_VALUE;
103
88
  var projMax = -Number.MAX_VALUE;
104
-
105
89
  var _iterator2 = _createForOfIteratorHelper(frustum.points),
106
- _step2;
107
-
90
+ _step2;
108
91
  try {
109
92
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
110
93
  var p = _step2.value;
@@ -117,17 +100,13 @@ var Aabb = /*#__PURE__*/function () {
117
100
  } finally {
118
101
  _iterator2.f();
119
102
  }
120
-
121
103
  if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
122
104
  return 0;
123
105
  }
124
106
  }
125
-
126
107
  return 1;
127
108
  }
128
109
  }]);
129
-
130
110
  return Aabb;
131
111
  }();
132
-
133
112
  export { Aabb as default };
package/es/utils/dom.js CHANGED
@@ -1,48 +1,35 @@
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
+ import { $window, isMini } from '@antv/l7-utils';
5
+ // @ts-ignore
9
6
  import Point from "../geo/point";
10
7
  var DOM = {};
11
8
  export default DOM;
12
-
13
9
  DOM.create = function (tagName, className, container) {
14
10
  var el = $window.document.createElement(tagName);
15
-
16
11
  if (className !== undefined) {
17
12
  el.className = className;
18
13
  }
19
-
20
14
  if (container) {
21
15
  container.appendChild(el);
22
16
  }
23
-
24
17
  return el;
25
18
  };
26
-
27
19
  DOM.createNS = function (namespaceURI, tagName) {
28
20
  var el = $window.document.createElementNS(namespaceURI, tagName);
29
21
  return el;
30
22
  };
31
-
32
23
  var docStyle = $window.document && $window.document.documentElement.style;
33
-
34
24
  function testProp(props) {
35
25
  if (!docStyle) {
36
26
  return props[0];
37
27
  }
38
-
39
28
  var _iterator = _createForOfIteratorHelper(props),
40
- _step;
41
-
29
+ _step;
42
30
  try {
43
31
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
32
  var i = _step.value;
45
-
46
33
  if (i in docStyle) {
47
34
  return i;
48
35
  }
@@ -52,37 +39,30 @@ function testProp(props) {
52
39
  } finally {
53
40
  _iterator.f();
54
41
  }
55
-
56
42
  return props[0];
57
43
  }
58
-
59
44
  var selectProp = testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);
60
45
  var userSelect;
61
-
62
46
  DOM.disableDrag = function () {
63
47
  if (docStyle && selectProp) {
64
48
  userSelect = docStyle[selectProp];
65
49
  docStyle[selectProp] = 'none';
66
50
  }
67
51
  };
68
-
69
52
  DOM.enableDrag = function () {
70
53
  if (docStyle && selectProp) {
71
54
  docStyle[selectProp] = userSelect;
72
55
  }
73
56
  };
74
-
75
57
  var transformProp = testProp(['transform', 'WebkitTransform']);
76
-
77
58
  DOM.setTransform = function (el, value) {
78
59
  // https://github.com/facebook/flow/issues/7754
79
60
  // $FlowFixMe
80
61
  el.style[transformProp] = value;
81
- }; // Feature detection for {passive: false} support in add/removeEventListener.
82
-
62
+ };
83
63
 
64
+ // Feature detection for {passive: false} support in add/removeEventListener.
84
65
  var passiveSupported = false;
85
-
86
66
  try {
87
67
  // https://github.com/facebook/flow/issues/285
88
68
  // $FlowFixMe
@@ -91,74 +71,66 @@ try {
91
71
  // eslint-disable-line
92
72
  passiveSupported = true;
93
73
  }
94
- }); // @ts-ignore
95
-
96
- $window.addEventListener('test', options, options); // @ts-ignore
97
-
74
+ });
75
+ // @ts-ignore
76
+ $window.addEventListener('test', options, options);
77
+ // @ts-ignore
98
78
  $window.removeEventListener('test', options, options);
99
79
  } catch (err) {
100
80
  passiveSupported = false;
101
81
  }
102
-
103
82
  DOM.addEventListener = function (target, type, callback) {
104
83
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
105
-
106
84
  if ('passive' in options && passiveSupported) {
107
85
  target.addEventListener(type, callback, options);
108
86
  } else {
109
87
  target.addEventListener(type, callback, options.capture);
110
88
  }
111
89
  };
112
-
113
90
  DOM.removeEventListener = function (target, type, callback) {
114
91
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
115
-
116
92
  if ('passive' in options && passiveSupported) {
117
93
  target.removeEventListener(type, callback, options);
118
94
  } else {
119
95
  target.removeEventListener(type, callback, options.capture);
120
96
  }
121
- }; // Suppress the next click, but only if it's immediate.
122
-
97
+ };
123
98
 
99
+ // Suppress the next click, but only if it's immediate.
124
100
  var suppressClick = function suppressClick(e) {
125
101
  e.preventDefault();
126
102
  e.stopPropagation();
127
103
  $window.removeEventListener('click', suppressClick, true);
128
104
  };
129
-
130
105
  DOM.suppressClick = function () {
131
106
  if (isMini) {
132
107
  return;
133
108
  }
134
-
135
109
  $window.addEventListener('click', suppressClick, true);
136
110
  setTimeout(function () {
137
111
  $window.removeEventListener('click', suppressClick, true);
138
112
  }, 0);
139
113
  };
140
-
141
114
  DOM.mousePos = function (el, e) {
142
115
  // 暂时从 el 上获取 top/left, 后面需要动态获取
143
116
  if (!isMini) {
144
117
  var rect = el.getBoundingClientRect();
145
118
  return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
146
119
  } else {
147
- return new Point( // @ts-ignore
148
- e.clientX - el.left - 0, // @ts-ignore
120
+ return new Point(
121
+ // @ts-ignore
122
+ e.clientX - el.left - 0,
123
+ // @ts-ignore
149
124
  e.clientY - el.top - 0);
150
125
  }
151
126
  };
152
-
153
127
  DOM.touchPos = function (el, touches) {
154
128
  // 暂时从 el 上获取 top/left, 后面需要动态获取
155
129
  if (!isMini) {
156
130
  var rect = el.getBoundingClientRect();
157
131
  var points = [];
158
-
159
132
  var _iterator2 = _createForOfIteratorHelper(touches),
160
- _step2;
161
-
133
+ _step2;
162
134
  try {
163
135
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
164
136
  var touche = _step2.value;
@@ -169,20 +141,18 @@ DOM.touchPos = function (el, touches) {
169
141
  } finally {
170
142
  _iterator2.f();
171
143
  }
172
-
173
144
  return points;
174
145
  } else {
175
146
  var _points = [];
176
-
177
147
  var _iterator3 = _createForOfIteratorHelper(touches),
178
- _step3;
179
-
148
+ _step3;
180
149
  try {
181
150
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
182
151
  var _touche = _step3.value;
183
-
184
- _points.push(new Point( // @ts-ignore
185
- _touche.clientX - el.left, // @ts-ignore
152
+ _points.push(new Point(
153
+ // @ts-ignore
154
+ _touche.clientX - el.left,
155
+ // @ts-ignore
186
156
  _touche.clientY - el.top));
187
157
  }
188
158
  } catch (err) {
@@ -190,27 +160,23 @@ DOM.touchPos = function (el, touches) {
190
160
  } finally {
191
161
  _iterator3.f();
192
162
  }
193
-
194
163
  return _points;
195
164
  }
196
165
  };
197
-
198
166
  DOM.mouseButton = function (e) {
199
167
  if (!isMini) {
200
168
  return e.button;
201
169
  }
202
-
203
- if ( // @ts-ignore
170
+ if (
171
+ // @ts-ignore
204
172
  typeof $window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
205
173
  // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
206
174
  // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
207
175
  // using Control + left click
208
176
  return 0;
209
177
  }
210
-
211
178
  return e.button;
212
179
  };
213
-
214
180
  DOM.remove = function (node) {
215
181
  if (node.parentNode) {
216
182
  node.parentNode.removeChild(node);
@@ -15,37 +15,38 @@ export var PerformanceUtils = {
15
15
  },
16
16
  frame: function frame(timestamp) {
17
17
  var currTimestamp = timestamp;
18
-
19
18
  if (lastFrameTime != null) {
20
19
  var frameTime = currTimestamp - lastFrameTime;
21
20
  frameTimes.push(frameTime);
22
21
  }
23
-
24
22
  lastFrameTime = currTimestamp;
25
23
  },
26
24
  clearMetrics: function clearMetrics() {
27
25
  lastFrameTime = null;
28
26
  frameTimes = [];
29
27
  performance.clearMeasures('loadTime');
30
- performance.clearMeasures('fullLoadTime'); // @ts-ignore
28
+ performance.clearMeasures('fullLoadTime');
29
+ // @ts-ignore
31
30
  // tslint:disable-next-line:forin
32
-
33
31
  for (var marker in PerformanceMarkers) {
34
32
  // @ts-ignore
35
33
  performance.clearMarks(PerformanceMarkers[marker]);
36
34
  }
37
35
  },
38
36
  getPerformanceMetrics: function getPerformanceMetrics() {
39
- var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load // @ts-ignore
37
+ var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load
38
+ // @ts-ignore
40
39
  ).duration;
41
- var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad // @ts-ignore
40
+ var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad
41
+ // @ts-ignore
42
42
  ).duration;
43
43
  var totalFrames = frameTimes.length;
44
44
  var avgFrameTime = frameTimes.reduce(function (prev, curr) {
45
45
  return prev + curr;
46
46
  }, 0) / totalFrames / 1000;
47
- var fps = 1 / avgFrameTime; // count frames that missed our framerate target
47
+ var fps = 1 / avgFrameTime;
48
48
 
49
+ // count frames that missed our framerate target
49
50
  var droppedFrames = frameTimes.filter(function (frameTime) {
50
51
  return frameTime > frameTimeTarget;
51
52
  }).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;