@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
@@ -1,20 +1,18 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  // @ts-ignore
4
- import { MapMouseEvent } from "./events";
5
4
 
5
+ import { MapMouseEvent } from "./events";
6
6
  var BlockableMapEventHandler = /*#__PURE__*/function () {
7
7
  function BlockableMapEventHandler(map) {
8
8
  _classCallCheck(this, BlockableMapEventHandler);
9
-
10
9
  this.map = map;
11
10
  }
12
-
13
11
  _createClass(BlockableMapEventHandler, [{
14
12
  key: "reset",
15
13
  value: function reset() {
16
- this.delayContextMenu = false; // @ts-ignore
17
-
14
+ this.delayContextMenu = false;
15
+ // @ts-ignore
18
16
  delete this.contextMenuEvent;
19
17
  }
20
18
  }, {
@@ -32,10 +30,9 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
32
30
  key: "mouseup",
33
31
  value: function mouseup() {
34
32
  this.delayContextMenu = false;
35
-
36
33
  if (this.contextMenuEvent) {
37
- this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent)); // @ts-ignore
38
-
34
+ this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
35
+ // @ts-ignore
39
36
  delete this.contextMenuEvent;
40
37
  }
41
38
  }
@@ -48,9 +45,9 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
48
45
  } else {
49
46
  // Windows: contextmenu fired on mouseup, so fire event now
50
47
  this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
51
- } // prevent browser context menu when necessary
52
-
48
+ }
53
49
 
50
+ // prevent browser context menu when necessary
54
51
  if (this.map.listeners('contextmenu')) {
55
52
  e.preventDefault();
56
53
  }
@@ -76,8 +73,6 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
76
73
  return false;
77
74
  }
78
75
  }]);
79
-
80
76
  return BlockableMapEventHandler;
81
77
  }();
82
-
83
78
  export { BlockableMapEventHandler as default };
@@ -1,78 +1,75 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  // @ts-ignore
4
+
4
5
  import DOM from "../utils/dom";
5
6
  import { Event } from "./events/event";
7
+
6
8
  /**
7
9
  * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
8
10
  * The bounding box is defined by clicking and holding `shift` while dragging the cursor.
9
11
  */
10
-
11
12
  var BoxZoomHandler = /*#__PURE__*/function () {
12
13
  /**
13
14
  * @private
14
15
  */
15
16
  function BoxZoomHandler(map, options) {
16
17
  _classCallCheck(this, BoxZoomHandler);
17
-
18
18
  this.map = map;
19
19
  this.el = map.getCanvasContainer();
20
20
  this.container = map.getContainer();
21
21
  this.clickTolerance = options.clickTolerance || 1;
22
22
  }
23
+
23
24
  /**
24
25
  * Returns a Boolean indicating whether the "box zoom" interaction is enabled.
25
26
  *
26
27
  * @returns {boolean} `true` if the "box zoom" interaction is enabled.
27
28
  */
28
-
29
-
30
29
  _createClass(BoxZoomHandler, [{
31
30
  key: "isEnabled",
32
31
  value: function isEnabled() {
33
32
  return !!this.enabled;
34
33
  }
34
+
35
35
  /**
36
36
  * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
37
37
  *
38
38
  * @returns {boolean} `true` if the "box zoom" interaction is active.
39
39
  */
40
-
41
40
  }, {
42
41
  key: "isActive",
43
42
  value: function isActive() {
44
43
  return !!this.active;
45
44
  }
45
+
46
46
  /**
47
47
  * Enables the "box zoom" interaction.
48
48
  *
49
49
  * @example
50
50
  * map.boxZoom.enable();
51
51
  */
52
-
53
52
  }, {
54
53
  key: "enable",
55
54
  value: function enable() {
56
55
  if (this.isEnabled()) {
57
56
  return;
58
57
  }
59
-
60
58
  this.enabled = true;
61
59
  }
60
+
62
61
  /**
63
62
  * Disables the "box zoom" interaction.
64
63
  *
65
64
  * @example
66
65
  * map.boxZoom.disable();
67
66
  */
68
-
69
67
  }, {
70
68
  key: "disable",
71
69
  value: function disable() {
72
70
  if (!this.isEnabled()) {
73
71
  return;
74
72
  }
75
-
76
73
  this.enabled = false;
77
74
  }
78
75
  }, {
@@ -81,11 +78,9 @@ var BoxZoomHandler = /*#__PURE__*/function () {
81
78
  if (!this.isEnabled()) {
82
79
  return;
83
80
  }
84
-
85
81
  if (!(e.shiftKey && e.button === 0)) {
86
82
  return;
87
83
  }
88
-
89
84
  DOM.disableDrag();
90
85
  this.startPos = this.lastPos = point;
91
86
  this.active = true;
@@ -96,28 +91,22 @@ var BoxZoomHandler = /*#__PURE__*/function () {
96
91
  if (!this.active) {
97
92
  return;
98
93
  }
99
-
100
94
  var pos = point;
101
-
102
95
  if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
103
96
  return;
104
97
  }
105
-
106
98
  var p0 = this.startPos;
107
99
  this.lastPos = pos;
108
-
109
100
  if (!this.box) {
110
101
  this.box = DOM.create('div', 'l7-boxzoom', this.container);
111
102
  this.container.classList.add('l7-crosshair');
112
103
  this.fireEvent('boxzoomstart', e);
113
104
  }
114
-
115
105
  var minX = Math.min(p0.x, pos.x);
116
106
  var maxX = Math.max(p0.x, pos.x);
117
107
  var minY = Math.min(p0.y, pos.y);
118
108
  var maxY = Math.max(p0.y, pos.y);
119
109
  DOM.setTransform(this.box, "translate(".concat(minX, "px,").concat(minY, "px)"));
120
-
121
110
  if (this.box) {
122
111
  this.box.style.width = "".concat(maxX - minX, "px");
123
112
  this.box.style.height = "".concat(maxY - minY, "px");
@@ -127,20 +116,16 @@ var BoxZoomHandler = /*#__PURE__*/function () {
127
116
  key: "mouseupWindow",
128
117
  value: function mouseupWindow(e, point) {
129
118
  var _this = this;
130
-
131
119
  if (!this.active) {
132
120
  return;
133
121
  }
134
-
135
122
  if (e.button !== 0) {
136
123
  return;
137
124
  }
138
-
139
125
  var p0 = this.startPos;
140
126
  var p1 = point;
141
127
  this.reset();
142
128
  DOM.suppressClick();
143
-
144
129
  if (p0.x === p1.x && p0.y === p1.y) {
145
130
  this.fireEvent('boxzoomcancel', e);
146
131
  } else {
@@ -162,7 +147,6 @@ var BoxZoomHandler = /*#__PURE__*/function () {
162
147
  if (!this.active) {
163
148
  return;
164
149
  }
165
-
166
150
  if (e.keyCode === 27) {
167
151
  this.reset();
168
152
  this.fireEvent('boxzoomcancel', e);
@@ -173,16 +157,14 @@ var BoxZoomHandler = /*#__PURE__*/function () {
173
157
  value: function reset() {
174
158
  this.active = false;
175
159
  this.container.classList.remove('l7-crosshair');
176
-
177
160
  if (this.box) {
178
161
  DOM.remove(this.box);
179
162
  this.box = null;
180
163
  }
181
-
182
- DOM.enableDrag(); // @ts-ignore
183
-
184
- delete this.startPos; // @ts-ignore
185
-
164
+ DOM.enableDrag();
165
+ // @ts-ignore
166
+ delete this.startPos;
167
+ // @ts-ignore
186
168
  delete this.lastPos;
187
169
  }
188
170
  }, {
@@ -193,8 +175,6 @@ var BoxZoomHandler = /*#__PURE__*/function () {
193
175
  }));
194
176
  }
195
177
  }]);
196
-
197
178
  return BoxZoomHandler;
198
179
  }();
199
-
200
180
  export default BoxZoomHandler;
@@ -1,14 +1,11 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
-
4
3
  // @ts-ignore
5
4
  var ClickZoomHandler = /*#__PURE__*/function () {
6
5
  function ClickZoomHandler() {
7
6
  _classCallCheck(this, ClickZoomHandler);
8
-
9
7
  this.reset();
10
8
  }
11
-
12
9
  _createClass(ClickZoomHandler, [{
13
10
  key: "reset",
14
11
  value: function reset() {
@@ -52,8 +49,6 @@ var ClickZoomHandler = /*#__PURE__*/function () {
52
49
  return this.active;
53
50
  }
54
51
  }]);
55
-
56
52
  return ClickZoomHandler;
57
53
  }();
58
-
59
54
  export { ClickZoomHandler as default };
@@ -1,12 +1,11 @@
1
1
  import _createClass from "@babel/runtime/helpers/esm/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  // tslint:disable-next-line:no-submodule-imports
4
- import merge from 'lodash/merge';
4
+ import { lodashUtil } from '@antv/l7-utils';
5
+ var merge = lodashUtil.merge;
5
6
  export var Event = /*#__PURE__*/_createClass(function Event(type) {
6
7
  var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
-
8
8
  _classCallCheck(this, Event);
9
-
10
9
  merge(this, data);
11
10
  this.type = type;
12
11
  });
@@ -3,22 +3,17 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  // @ts-ignore
12
9
  // tslint:disable-next-line:no-submodule-imports
13
- import merge from 'lodash/merge';
10
+ import { lodashUtil } from '@antv/l7-utils';
14
11
  import DOM from "../../utils/dom";
15
12
  import { Event } from "./event";
16
-
13
+ var merge = lodashUtil.merge;
17
14
  var MapMouseEvent = /*#__PURE__*/function (_Event) {
18
15
  _inherits(MapMouseEvent, _Event);
19
-
20
16
  var _super = _createSuper(MapMouseEvent);
21
-
22
17
  /**
23
18
  * `true` if `preventDefault` has been called.
24
19
  * @private
@@ -45,11 +40,8 @@ var MapMouseEvent = /*#__PURE__*/function (_Event) {
45
40
  */
46
41
  function MapMouseEvent(type, map, originalEvent) {
47
42
  var _this;
48
-
49
43
  var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
50
-
51
44
  _classCallCheck(this, MapMouseEvent);
52
-
53
45
  var point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
54
46
  var lngLat = map.unproject(point);
55
47
  _this = _super.call(this, type, merge({
@@ -61,15 +53,12 @@ var MapMouseEvent = /*#__PURE__*/function (_Event) {
61
53
  _this.target = map;
62
54
  return _this;
63
55
  }
64
-
65
56
  _createClass(MapMouseEvent, [{
66
57
  key: "preventDefault",
67
58
  value: function preventDefault() {
68
59
  this.defaultPrevented = true;
69
60
  }
70
61
  }]);
71
-
72
62
  return MapMouseEvent;
73
63
  }(Event);
74
-
75
64
  export { MapMouseEvent as default };
@@ -3,21 +3,16 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  // @ts-ignore
9
+
12
10
  import Point from "../../geo/point";
13
11
  import DOM from "../../utils/dom";
14
12
  import { Event } from "./event";
15
-
16
13
  var MapTouchEvent = /*#__PURE__*/function (_Event) {
17
14
  _inherits(MapTouchEvent, _Event);
18
-
19
15
  var _super = _createSuper(MapTouchEvent);
20
-
21
16
  /**
22
17
  * The event type.
23
18
  */
@@ -59,9 +54,7 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
59
54
  */
60
55
  function MapTouchEvent(type, map, originalEvent) {
61
56
  var _this;
62
-
63
57
  _classCallCheck(this, MapTouchEvent);
64
-
65
58
  var touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
66
59
  var points = DOM.touchPos(map.getCanvasContainer(), touches);
67
60
  var lngLats = points.map(function (t) {
@@ -81,6 +74,7 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
81
74
  _this.defaultPrevented = false;
82
75
  return _this;
83
76
  }
77
+
84
78
  /**
85
79
  * Prevents subsequent default processing of the event by the map.
86
80
  *
@@ -90,16 +84,12 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
90
84
  * * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
91
85
  *
92
86
  */
93
-
94
-
95
87
  _createClass(MapTouchEvent, [{
96
88
  key: "preventDefault",
97
89
  value: function preventDefault() {
98
90
  this.defaultPrevented = true;
99
91
  }
100
92
  }]);
101
-
102
93
  return MapTouchEvent;
103
94
  }(Event);
104
-
105
95
  export { MapTouchEvent as default };
@@ -3,18 +3,12 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import { Event } from "./event";
12
-
13
9
  var MapWheelEvent = /*#__PURE__*/function (_Event) {
14
10
  _inherits(MapWheelEvent, _Event);
15
-
16
11
  var _super = _createSuper(MapWheelEvent);
17
-
18
12
  /**
19
13
  * The event type.
20
14
  */
@@ -32,30 +26,25 @@ var MapWheelEvent = /*#__PURE__*/function (_Event) {
32
26
  */
33
27
  function MapWheelEvent(type, map, originalEvent) {
34
28
  var _this;
35
-
36
29
  _classCallCheck(this, MapWheelEvent);
37
-
38
30
  _this = _super.call(this, type, {
39
31
  originalEvent: originalEvent
40
32
  });
41
33
  _this.defaultPrevented = false;
42
34
  return _this;
43
35
  }
36
+
44
37
  /**
45
38
  * Prevents subsequent default processing of the event by the map.
46
39
  *
47
40
  * Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
48
41
  */
49
-
50
-
51
42
  _createClass(MapWheelEvent, [{
52
43
  key: "preventDefault",
53
44
  value: function preventDefault() {
54
45
  this.defaultPrevented = true;
55
46
  }
56
47
  }]);
57
-
58
48
  return MapWheelEvent;
59
49
  }(Event);
60
-
61
50
  export { MapWheelEvent as default };
@@ -5,35 +5,22 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
-
9
8
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
10
  import { Event } from "./event";
14
-
15
11
  var RenderFrameEvent = /*#__PURE__*/function (_Event) {
16
12
  _inherits(RenderFrameEvent, _Event);
17
-
18
13
  var _super = _createSuper(RenderFrameEvent);
19
-
20
14
  function RenderFrameEvent() {
21
15
  var _this;
22
-
23
16
  _classCallCheck(this, RenderFrameEvent);
24
-
25
17
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
18
  args[_key] = arguments[_key];
27
19
  }
28
-
29
20
  _this = _super.call.apply(_super, [this].concat(args));
30
-
31
21
  _defineProperty(_assertThisInitialized(_this), "type", 'renderFrame');
32
-
33
22
  return _this;
34
23
  }
35
-
36
24
  return _createClass(RenderFrameEvent);
37
25
  }(Event);
38
-
39
26
  export { RenderFrameEvent as default };
@@ -1,17 +1,15 @@
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
  // @ts-ignore
11
- import Point from "../geo/point"; // tslint:disable-next-line:no-submodule-imports
7
+ import Point from "../geo/point";
12
8
 
13
- import merge from 'lodash/merge';
9
+ // tslint:disable-next-line:no-submodule-imports
10
+ import { lodashUtil } from '@antv/l7-utils';
14
11
  import { bezier, clamp, now } from "../util";
12
+ var merge = lodashUtil.merge;
15
13
  var defaultInertiaOptions = {
16
14
  linearity: 0.3,
17
15
  easing: bezier(0, 0, 0.3, 1)
@@ -32,15 +30,12 @@ var defaultPitchInertiaOptions = merge({
32
30
  deceleration: 1000,
33
31
  maxSpeed: 90
34
32
  }, defaultInertiaOptions);
35
-
36
33
  var HandlerInertia = /*#__PURE__*/function () {
37
34
  function HandlerInertia(map) {
38
35
  _classCallCheck(this, HandlerInertia);
39
-
40
36
  this.map = map;
41
37
  this.clear();
42
38
  }
43
-
44
39
  _createClass(HandlerInertia, [{
45
40
  key: "clear",
46
41
  value: function clear() {
@@ -70,11 +65,9 @@ var HandlerInertia = /*#__PURE__*/function () {
70
65
  key: "onMoveEnd",
71
66
  value: function onMoveEnd(panInertiaOptions) {
72
67
  this.drainInertiaBuffer();
73
-
74
68
  if (this.inertiaBuffer.length < 2) {
75
69
  return;
76
70
  }
77
-
78
71
  var deltas = {
79
72
  zoom: 0,
80
73
  bearing: 0,
@@ -83,25 +76,20 @@ var HandlerInertia = /*#__PURE__*/function () {
83
76
  pinchAround: undefined,
84
77
  around: undefined
85
78
  };
86
-
87
79
  var _iterator = _createForOfIteratorHelper(this.inertiaBuffer),
88
- _step;
89
-
80
+ _step;
90
81
  try {
91
82
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
83
  var settings = _step.value.settings;
93
84
  deltas.zoom += settings.zoomDelta || 0;
94
85
  deltas.bearing += settings.bearingDelta || 0;
95
86
  deltas.pitch += settings.pitchDelta || 0;
96
-
97
87
  if (settings.panDelta) {
98
88
  deltas.pan._add(settings.panDelta);
99
89
  }
100
-
101
90
  if (settings.around) {
102
91
  deltas.around = settings.around;
103
92
  }
104
-
105
93
  if (settings.pinchAround) {
106
94
  deltas.pinchAround = settings.pinchAround;
107
95
  }
@@ -111,69 +99,54 @@ var HandlerInertia = /*#__PURE__*/function () {
111
99
  } finally {
112
100
  _iterator.f();
113
101
  }
114
-
115
102
  var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
116
103
  var duration = lastEntry.time - this.inertiaBuffer[0].time;
117
104
  var easeOptions = {};
118
-
119
105
  if (deltas.pan.mag()) {
120
106
  var result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
121
107
  easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
122
108
  easeOptions.center = this.map.transform.center;
123
109
  extendDuration(easeOptions, result);
124
110
  }
125
-
126
111
  if (deltas.zoom) {
127
112
  var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
128
-
129
113
  easeOptions.zoom = this.map.transform.zoom + _result.amount;
130
114
  extendDuration(easeOptions, _result);
131
115
  }
132
-
133
116
  if (deltas.bearing) {
134
117
  var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
135
-
136
118
  easeOptions.bearing = this.map.transform.bearing + clamp(_result2.amount, -179, 179);
137
119
  extendDuration(easeOptions, _result2);
138
120
  }
139
-
140
121
  if (deltas.pitch) {
141
122
  var _result3 = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
142
-
143
123
  easeOptions.pitch = this.map.transform.pitch + _result3.amount;
144
124
  extendDuration(easeOptions, _result3);
145
125
  }
146
-
147
126
  if (easeOptions.zoom || easeOptions.bearing) {
148
127
  var last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
149
128
  easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
150
129
  }
151
-
152
130
  this.clear();
153
131
  return merge(easeOptions, {
154
132
  noMoveStart: true
155
133
  });
156
134
  }
157
135
  }]);
158
-
159
136
  return HandlerInertia;
160
137
  }(); // Unfortunately zoom, bearing, etc can't have different durations and easings so
161
138
  // we need to choose one. We use the longest duration and it's corresponding easing.
162
-
163
-
164
139
  export { HandlerInertia as default };
165
-
166
140
  function extendDuration(easeOptions, result) {
167
141
  if (!easeOptions.duration || easeOptions.duration < result.duration) {
168
142
  easeOptions.duration = result.duration;
169
143
  easeOptions.easing = result.easing;
170
144
  }
171
145
  }
172
-
173
146
  function calculateEasing(amount, inertiaDuration, inertiaOptions) {
174
147
  var maxSpeed = inertiaOptions.maxSpeed,
175
- linearity = inertiaOptions.linearity,
176
- deceleration = inertiaOptions.deceleration;
148
+ linearity = inertiaOptions.linearity,
149
+ deceleration = inertiaOptions.deceleration;
177
150
  var speed = clamp(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
178
151
  var duration = Math.abs(speed) / (deceleration * linearity);
179
152
  return {