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