@antv/l7-map 2.5.34 → 2.5.37-mini10

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 (183) hide show
  1. package/lib/geo/lng_lat.js +1 -1
  2. package/lib/geo/mercator.js +11 -7
  3. package/lib/geo/mercator.js.map +1 -1
  4. package/lib/geo/simple.js +11 -7
  5. package/lib/geo/simple.js.map +1 -1
  6. package/lib/geo/transform.js +6 -2
  7. package/lib/geo/transform.js.map +1 -1
  8. package/lib/handler/mouse/index.js +4 -4
  9. package/lib/handler/mouse/util.js +1 -1
  10. package/lib/handler/scroll_zoom.js +1 -1
  11. package/lib/handler/scroll_zoom.js.map +1 -1
  12. package/lib/handler/tap/single_tap_recognizer.js +1 -1
  13. package/lib/handler/tap/tap_recognizer.js +6 -2
  14. package/lib/handler/tap/tap_recognizer.js.map +1 -1
  15. package/lib/util.js +7 -4
  16. package/lib/util.js.map +1 -1
  17. package/package.json +3 -3
  18. package/LICENSE.md +0 -21
  19. package/es/camera.d.ts +0 -82
  20. package/es/camera.js +0 -729
  21. package/es/camera.js.map +0 -1
  22. package/es/earthmap.d.ts +0 -67
  23. package/es/earthmap.js +0 -454
  24. package/es/earthmap.js.map +0 -1
  25. package/es/geo/edge_insets.d.ts +0 -54
  26. package/es/geo/edge_insets.js +0 -88
  27. package/es/geo/edge_insets.js.map +0 -1
  28. package/es/geo/lng_lat.d.ts +0 -18
  29. package/es/geo/lng_lat.js +0 -77
  30. package/es/geo/lng_lat.js.map +0 -1
  31. package/es/geo/lng_lat_bounds.d.ts +0 -24
  32. package/es/geo/lng_lat_bounds.js +0 -170
  33. package/es/geo/lng_lat_bounds.js.map +0 -1
  34. package/es/geo/mercator.d.ts +0 -28
  35. package/es/geo/mercator.js +0 -79
  36. package/es/geo/mercator.js.map +0 -1
  37. package/es/geo/point.d.ts +0 -40
  38. package/es/geo/point.js +0 -237
  39. package/es/geo/point.js.map +0 -1
  40. package/es/geo/simple.d.ts +0 -28
  41. package/es/geo/simple.js +0 -78
  42. package/es/geo/simple.js.map +0 -1
  43. package/es/geo/transform.d.ts +0 -198
  44. package/es/geo/transform.js +0 -663
  45. package/es/geo/transform.js.map +0 -1
  46. package/es/handler/IHandler.d.ts +0 -34
  47. package/es/handler/IHandler.js +0 -2
  48. package/es/handler/IHandler.js.map +0 -1
  49. package/es/handler/blockable_map_event.d.ts +0 -17
  50. package/es/handler/blockable_map_event.js +0 -84
  51. package/es/handler/blockable_map_event.js.map +0 -1
  52. package/es/handler/box_zoom.d.ts +0 -59
  53. package/es/handler/box_zoom.js +0 -184
  54. package/es/handler/box_zoom.js.map +0 -1
  55. package/es/handler/click_zoom.d.ts +0 -16
  56. package/es/handler/click_zoom.js +0 -64
  57. package/es/handler/click_zoom.js.map +0 -1
  58. package/es/handler/events/event.d.ts +0 -4
  59. package/es/handler/events/event.js +0 -14
  60. package/es/handler/events/event.js.map +0 -1
  61. package/es/handler/events/index.d.ts +0 -4
  62. package/es/handler/events/index.js +0 -5
  63. package/es/handler/events/index.js.map +0 -1
  64. package/es/handler/events/map_mouse_event.d.ts +0 -34
  65. package/es/handler/events/map_mouse_event.js +0 -65
  66. package/es/handler/events/map_mouse_event.js.map +0 -1
  67. package/es/handler/events/map_touch_event.d.ts +0 -57
  68. package/es/handler/events/map_touch_event.js +0 -75
  69. package/es/handler/events/map_touch_event.js.map +0 -1
  70. package/es/handler/events/map_wheel_event.d.ts +0 -33
  71. package/es/handler/events/map_wheel_event.js +0 -52
  72. package/es/handler/events/map_wheel_event.js.map +0 -1
  73. package/es/handler/events/render_event.d.ts +0 -5
  74. package/es/handler/events/render_event.js +0 -41
  75. package/es/handler/events/render_event.js.map +0 -1
  76. package/es/handler/handler_inertia.d.ts +0 -23
  77. package/es/handler/handler_inertia.js +0 -186
  78. package/es/handler/handler_inertia.js.map +0 -1
  79. package/es/handler/handler_manager.d.ts +0 -57
  80. package/es/handler/handler_manager.js +0 -655
  81. package/es/handler/handler_manager.js.map +0 -1
  82. package/es/handler/handler_util.d.ts +0 -4
  83. package/es/handler/handler_util.js +0 -10
  84. package/es/handler/handler_util.js.map +0 -1
  85. package/es/handler/keyboard.d.ts +0 -36
  86. package/es/handler/keyboard.js +0 -157
  87. package/es/handler/keyboard.js.map +0 -1
  88. package/es/handler/map_event.d.ts +0 -29
  89. package/es/handler/map_event.js +0 -120
  90. package/es/handler/map_event.js.map +0 -1
  91. package/es/handler/mouse/index.d.ts +0 -4
  92. package/es/handler/mouse/index.js +0 -5
  93. package/es/handler/mouse/index.js.map +0 -1
  94. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  95. package/es/handler/mouse/mouse_handler.js +0 -131
  96. package/es/handler/mouse/mouse_handler.js.map +0 -1
  97. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  98. package/es/handler/mouse/mousepan_handler.js +0 -54
  99. package/es/handler/mouse/mousepan_handler.js.map +0 -1
  100. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  101. package/es/handler/mouse/mousepitch_hander.js +0 -54
  102. package/es/handler/mouse/mousepitch_hander.js.map +0 -1
  103. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  104. package/es/handler/mouse/mouserotate_hander.js +0 -54
  105. package/es/handler/mouse/mouserotate_hander.js.map +0 -1
  106. package/es/handler/mouse/util.d.ts +0 -6
  107. package/es/handler/mouse/util.js +0 -12
  108. package/es/handler/mouse/util.js.map +0 -1
  109. package/es/handler/scroll_zoom.d.ts +0 -93
  110. package/es/handler/scroll_zoom.js +0 -317
  111. package/es/handler/scroll_zoom.js.map +0 -1
  112. package/es/handler/shim/dblclick_zoom.d.ts +0 -40
  113. package/es/handler/shim/dblclick_zoom.js +0 -45
  114. package/es/handler/shim/dblclick_zoom.js.map +0 -1
  115. package/es/handler/shim/drag_pan.d.ts +0 -61
  116. package/es/handler/shim/drag_pan.js +0 -53
  117. package/es/handler/shim/drag_pan.js.map +0 -1
  118. package/es/handler/shim/drag_rotate.d.ts +0 -46
  119. package/es/handler/shim/drag_rotate.js +0 -51
  120. package/es/handler/shim/drag_rotate.js.map +0 -1
  121. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  122. package/es/handler/shim/touch_zoom_rotate.js +0 -80
  123. package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
  124. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  125. package/es/handler/tap/single_tap_recognizer.js +0 -127
  126. package/es/handler/tap/single_tap_recognizer.js.map +0 -1
  127. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  128. package/es/handler/tap/tap_drag_zoom.js +0 -124
  129. package/es/handler/tap/tap_drag_zoom.js.map +0 -1
  130. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  131. package/es/handler/tap/tap_recognizer.js +0 -72
  132. package/es/handler/tap/tap_recognizer.js.map +0 -1
  133. package/es/handler/tap/tap_zoom.d.ts +0 -22
  134. package/es/handler/tap/tap_zoom.js +0 -124
  135. package/es/handler/tap/tap_zoom.js.map +0 -1
  136. package/es/handler/touch/index.d.ts +0 -5
  137. package/es/handler/touch/index.js +0 -6
  138. package/es/handler/touch/index.js.map +0 -1
  139. package/es/handler/touch/touch_pan.d.ts +0 -30
  140. package/es/handler/touch/touch_pan.js +0 -139
  141. package/es/handler/touch/touch_pan.js.map +0 -1
  142. package/es/handler/touch/touch_pitch.d.ts +0 -13
  143. package/es/handler/touch/touch_pitch.js +0 -120
  144. package/es/handler/touch/touch_pitch.js.map +0 -1
  145. package/es/handler/touch/touch_rotate.d.ts +0 -12
  146. package/es/handler/touch/touch_rotate.js +0 -88
  147. package/es/handler/touch/touch_rotate.js.map +0 -1
  148. package/es/handler/touch/touch_zoom.d.ts +0 -12
  149. package/es/handler/touch/touch_zoom.js +0 -79
  150. package/es/handler/touch/touch_zoom.js.map +0 -1
  151. package/es/handler/touch/two_touch.d.ts +0 -23
  152. package/es/handler/touch/two_touch.js +0 -140
  153. package/es/handler/touch/two_touch.js.map +0 -1
  154. package/es/hash.d.ts +0 -15
  155. package/es/hash.js +0 -143
  156. package/es/hash.js.map +0 -1
  157. package/es/index.d.ts +0 -2
  158. package/es/index.js +0 -3
  159. package/es/index.js.map +0 -1
  160. package/es/interface.d.ts +0 -31
  161. package/es/interface.js +0 -2
  162. package/es/interface.js.map +0 -1
  163. package/es/map.d.ts +0 -67
  164. package/es/map.js +0 -454
  165. package/es/map.js.map +0 -1
  166. package/es/util.d.ts +0 -18
  167. package/es/util.js +0 -74
  168. package/es/util.js.map +0 -1
  169. package/es/utils/Aabb.d.ts +0 -12
  170. package/es/utils/Aabb.js +0 -134
  171. package/es/utils/Aabb.js.map +0 -1
  172. package/es/utils/dom.d.ts +0 -4
  173. package/es/utils/dom.js +0 -165
  174. package/es/utils/dom.js.map +0 -1
  175. package/es/utils/performance.d.ts +0 -17
  176. package/es/utils/performance.js +0 -57
  177. package/es/utils/performance.js.map +0 -1
  178. package/es/utils/primitives.d.ts +0 -6
  179. package/es/utils/primitives.js +0 -44
  180. package/es/utils/primitives.js.map +0 -1
  181. package/es/utils/task_queue.d.ts +0 -13
  182. package/es/utils/task_queue.js +0 -113
  183. package/es/utils/task_queue.js.map +0 -1
@@ -1,655 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
-
6
- 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; } } }; }
7
-
8
- 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); }
9
-
10
- 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; }
11
-
12
- import merge from 'lodash/merge';
13
- import Point from '../geo/point';
14
- import DOM from '../utils/dom';
15
- import BlockableMapEventHandler from './blockable_map_event';
16
- import BoxZoomHandler from './box_zoom';
17
- import ClickZoomHandler from './click_zoom';
18
- import { Event } from './events/event';
19
- import RenderFrameEvent from './events/render_event';
20
- import HandlerInertia from './handler_inertia';
21
- import KeyboardHandler from './keyboard';
22
- import MapEventHandler from './map_event';
23
- import { MousePanHandler, MousePitchHandler, MouseRotateHandler } from './mouse';
24
- import ScrollZoomHandler from './scroll_zoom';
25
- import DoubleClickZoomHandler from './shim/dblclick_zoom';
26
- import DragPanHandler from './shim/drag_pan';
27
- import DragRotateHandler from './shim/drag_rotate';
28
- import TouchZoomRotateHandler from './shim/touch_zoom_rotate';
29
- import TapDragZoomHandler from './tap/tap_drag_zoom';
30
- import TapZoomHandler from './tap/tap_zoom';
31
- import { TouchPanHandler, TouchPitchHandler, TouchRotateHandler, TouchZoomHandler } from './touch';
32
-
33
- var _isMoving = function isMoving(p) {
34
- return p.zoom || p.drag || p.pitch || p.rotate;
35
- };
36
-
37
- function hasChange(result) {
38
- return result.panDelta && result.panDelta.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta;
39
- }
40
-
41
- var HandlerManager = function () {
42
- function HandlerManager(map, options) {
43
- var _this = this;
44
-
45
- _classCallCheck(this, HandlerManager);
46
-
47
- _defineProperty(this, "map", void 0);
48
-
49
- _defineProperty(this, "el", void 0);
50
-
51
- _defineProperty(this, "handlers", void 0);
52
-
53
- _defineProperty(this, "eventsInProgress", void 0);
54
-
55
- _defineProperty(this, "frameId", void 0);
56
-
57
- _defineProperty(this, "inertia", void 0);
58
-
59
- _defineProperty(this, "bearingSnap", void 0);
60
-
61
- _defineProperty(this, "handlersById", void 0);
62
-
63
- _defineProperty(this, "updatingCamera", void 0);
64
-
65
- _defineProperty(this, "changes", void 0);
66
-
67
- _defineProperty(this, "previousActiveHandlers", void 0);
68
-
69
- _defineProperty(this, "bearingChanged", void 0);
70
-
71
- _defineProperty(this, "listeners", void 0);
72
-
73
- _defineProperty(this, "handleWindowEvent", function (e) {
74
- _this.handleEvent(e, "".concat(e.type, "Window"));
75
- });
76
-
77
- _defineProperty(this, "handleEvent", function (e, eventName) {
78
- if (e.type === 'blur') {
79
- _this.stop();
80
-
81
- return;
82
- }
83
-
84
- _this.updatingCamera = true;
85
- var inputEvent = e.type === 'renderFrame' ? undefined : e;
86
- var mergedIHandlerResult = {
87
- needsRenderFrame: false
88
- };
89
- var eventsInProgress = {};
90
- var activeHandlers = {};
91
- var mapTouches = e.touches ? _this.getMapTouches(e.touches) : undefined;
92
- var points = mapTouches ? DOM.touchPos(_this.el, mapTouches) : DOM.mousePos(_this.el, e);
93
-
94
- var _iterator = _createForOfIteratorHelper(_this.handlers),
95
- _step;
96
-
97
- try {
98
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
- var _step$value = _step.value,
100
- handlerName = _step$value.handlerName,
101
- handler = _step$value.handler,
102
- allowed = _step$value.allowed;
103
-
104
- if (!handler.isEnabled()) {
105
- continue;
106
- }
107
-
108
- var data = void 0;
109
-
110
- if (_this.blockedByActive(activeHandlers, allowed, handlerName)) {
111
- handler.reset();
112
- } else {
113
- var handerName = eventName || e.type;
114
-
115
- if (handler && handler[handerName]) {
116
- data = handler[handerName](e, points, mapTouches);
117
-
118
- _this.mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, data, handlerName, inputEvent);
119
-
120
- if (data && data.needsRenderFrame) {
121
- _this.triggerRenderFrame();
122
- }
123
- }
124
- }
125
-
126
- if (data || handler.isActive()) {
127
- activeHandlers[handlerName] = handler;
128
- }
129
- }
130
- } catch (err) {
131
- _iterator.e(err);
132
- } finally {
133
- _iterator.f();
134
- }
135
-
136
- var deactivatedHandlers = {};
137
-
138
- for (var name in _this.previousActiveHandlers) {
139
- if (!activeHandlers[name]) {
140
- deactivatedHandlers[name] = inputEvent;
141
- }
142
- }
143
-
144
- _this.previousActiveHandlers = activeHandlers;
145
-
146
- if (Object.keys(deactivatedHandlers).length || hasChange(mergedIHandlerResult)) {
147
- _this.changes.push([mergedIHandlerResult, eventsInProgress, deactivatedHandlers]);
148
-
149
- _this.triggerRenderFrame();
150
- }
151
-
152
- if (Object.keys(activeHandlers).length || hasChange(mergedIHandlerResult)) {
153
- _this.map.stop(true);
154
- }
155
-
156
- _this.updatingCamera = false;
157
- var cameraAnimation = mergedIHandlerResult.cameraAnimation;
158
-
159
- if (cameraAnimation) {
160
- _this.inertia.clear();
161
-
162
- _this.fireEvents({}, {});
163
-
164
- _this.changes = [];
165
- cameraAnimation(_this.map);
166
- }
167
- });
168
-
169
- this.map = map;
170
- this.el = this.map.getCanvasContainer();
171
- this.handlers = [];
172
- this.handlersById = {};
173
- this.changes = [];
174
- this.inertia = new HandlerInertia(map);
175
- this.bearingSnap = options.bearingSnap;
176
- this.previousActiveHandlers = {};
177
- this.eventsInProgress = {};
178
- this.addDefaultHandlers(options);
179
- var el = this.el;
180
- this.listeners = [[el, 'touchstart', {
181
- passive: false
182
- }], [el, 'touchmove', {
183
- passive: false
184
- }], [el, 'touchend', undefined], [el, 'touchcancel', undefined], [el, 'mousedown', undefined], [el, 'mousemove', undefined], [el, 'mouseup', undefined], [window.document, 'mousemove', {
185
- capture: true
186
- }], [window.document, 'mouseup', undefined], [el, 'mouseover', undefined], [el, 'mouseout', undefined], [el, 'dblclick', undefined], [el, 'click', undefined], [el, 'keydown', {
187
- capture: false
188
- }], [el, 'keyup', undefined], [el, 'wheel', {
189
- passive: false
190
- }], [el, 'contextmenu', undefined], [window, 'blur', undefined]];
191
-
192
- var _iterator2 = _createForOfIteratorHelper(this.listeners),
193
- _step2;
194
-
195
- try {
196
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
197
- var _step2$value = _slicedToArray(_step2.value, 3),
198
- target = _step2$value[0],
199
- type = _step2$value[1],
200
- listenerOptions = _step2$value[2];
201
-
202
- DOM.addEventListener(target, type, target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
203
- }
204
- } catch (err) {
205
- _iterator2.e(err);
206
- } finally {
207
- _iterator2.f();
208
- }
209
- }
210
-
211
- _createClass(HandlerManager, [{
212
- key: "destroy",
213
- value: function destroy() {
214
- var _iterator3 = _createForOfIteratorHelper(this.listeners),
215
- _step3;
216
-
217
- try {
218
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
219
- var _step3$value = _slicedToArray(_step3.value, 3),
220
- target = _step3$value[0],
221
- type = _step3$value[1],
222
- listenerOptions = _step3$value[2];
223
-
224
- DOM.removeEventListener(target, type, target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
225
- }
226
- } catch (err) {
227
- _iterator3.e(err);
228
- } finally {
229
- _iterator3.f();
230
- }
231
- }
232
- }, {
233
- key: "stop",
234
- value: function stop() {
235
- if (this.updatingCamera) {
236
- return;
237
- }
238
-
239
- var _iterator4 = _createForOfIteratorHelper(this.handlers),
240
- _step4;
241
-
242
- try {
243
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
244
- var handler = _step4.value.handler;
245
- handler.reset();
246
- }
247
- } catch (err) {
248
- _iterator4.e(err);
249
- } finally {
250
- _iterator4.f();
251
- }
252
-
253
- this.inertia.clear();
254
- this.fireEvents({}, {});
255
- this.changes = [];
256
- }
257
- }, {
258
- key: "isActive",
259
- value: function isActive() {
260
- var _iterator5 = _createForOfIteratorHelper(this.handlers),
261
- _step5;
262
-
263
- try {
264
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
265
- var handler = _step5.value.handler;
266
-
267
- if (handler.isActive()) {
268
- return true;
269
- }
270
- }
271
- } catch (err) {
272
- _iterator5.e(err);
273
- } finally {
274
- _iterator5.f();
275
- }
276
-
277
- return false;
278
- }
279
- }, {
280
- key: "isZooming",
281
- value: function isZooming() {
282
- return !!this.eventsInProgress.zoom || this.map.scrollZoom.isZooming();
283
- }
284
- }, {
285
- key: "isRotating",
286
- value: function isRotating() {
287
- return !!this.eventsInProgress.rotate;
288
- }
289
- }, {
290
- key: "isMoving",
291
- value: function isMoving() {
292
- return Boolean(_isMoving(this.eventsInProgress)) || this.isZooming();
293
- }
294
- }, {
295
- key: "mergeIHandlerResult",
296
- value: function mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, HandlerResult, name, e) {
297
- if (!HandlerResult) {
298
- return;
299
- }
300
-
301
- merge(mergedIHandlerResult, HandlerResult);
302
- var eventData = {
303
- handlerName: name,
304
- originalEvent: HandlerResult.originalEvent || e
305
- };
306
-
307
- if (HandlerResult.zoomDelta !== undefined) {
308
- eventsInProgress.zoom = eventData;
309
- }
310
-
311
- if (HandlerResult.panDelta !== undefined) {
312
- eventsInProgress.drag = eventData;
313
- }
314
-
315
- if (HandlerResult.pitchDelta !== undefined) {
316
- eventsInProgress.pitch = eventData;
317
- }
318
-
319
- if (HandlerResult.bearingDelta !== undefined) {
320
- eventsInProgress.rotate = eventData;
321
- }
322
- }
323
- }, {
324
- key: "triggerRenderFrame",
325
- value: function triggerRenderFrame() {
326
- var _this2 = this;
327
-
328
- if (this.frameId === undefined) {
329
- this.frameId = this.map.requestRenderFrame(function (timeStamp) {
330
- delete _this2.frameId;
331
-
332
- _this2.handleEvent(new RenderFrameEvent('renderFrame', {
333
- timeStamp: timeStamp
334
- }));
335
-
336
- _this2.applyChanges();
337
- });
338
- }
339
- }
340
- }, {
341
- key: "addDefaultHandlers",
342
- value: function addDefaultHandlers(options) {
343
- var map = this.map;
344
- var el = map.getCanvasContainer();
345
- this.add('mapEvent', new MapEventHandler(map, options));
346
- var boxZoom = map.boxZoom = new BoxZoomHandler(map, options);
347
- this.add('boxZoom', boxZoom);
348
- var tapZoom = new TapZoomHandler();
349
- var clickZoom = new ClickZoomHandler();
350
- map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);
351
- this.add('tapZoom', tapZoom);
352
- this.add('clickZoom', clickZoom);
353
- var tapDragZoom = new TapDragZoomHandler();
354
- this.add('tapDragZoom', tapDragZoom);
355
- var touchPitch = map.touchPitch = new TouchPitchHandler();
356
- this.add('touchPitch', touchPitch);
357
- var mouseRotate = new MouseRotateHandler(options);
358
- var mousePitch = new MousePitchHandler(options);
359
- map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);
360
- this.add('mouseRotate', mouseRotate, ['mousePitch']);
361
- this.add('mousePitch', mousePitch, ['mouseRotate']);
362
- var mousePan = new MousePanHandler(options);
363
- var touchPan = new TouchPanHandler(options);
364
- map.dragPan = new DragPanHandler(el, mousePan, touchPan);
365
- this.add('mousePan', mousePan);
366
- this.add('touchPan', touchPan, ['touchZoom', 'touchRotate']);
367
- var touchRotate = new TouchRotateHandler();
368
- var touchZoom = new TouchZoomHandler();
369
- map.touchZoomRotate = new TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);
370
- this.add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);
371
- this.add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);
372
- var scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, this);
373
- this.add('scrollZoom', scrollZoom, ['mousePan']);
374
- var keyboard = map.keyboard = new KeyboardHandler();
375
- this.add('keyboard', keyboard);
376
- this.add('blockableMapEvent', new BlockableMapEventHandler(map));
377
-
378
- for (var _i = 0, _arr = ['boxZoom', 'doubleClickZoom', 'tapDragZoom', 'touchPitch', 'dragRotate', 'dragPan', 'touchZoomRotate', 'scrollZoom', 'keyboard']; _i < _arr.length; _i++) {
379
- var name = _arr[_i];
380
-
381
- if (options.interactive && options[name]) {
382
- map[name].enable(options[name]);
383
- }
384
- }
385
- }
386
- }, {
387
- key: "add",
388
- value: function add(handlerName, handler, allowed) {
389
- this.handlers.push({
390
- handlerName: handlerName,
391
- handler: handler,
392
- allowed: allowed
393
- });
394
- this.handlersById[handlerName] = handler;
395
- }
396
- }, {
397
- key: "blockedByActive",
398
- value: function blockedByActive(activeHandlers, allowed, myName) {
399
- for (var name in activeHandlers) {
400
- if (name === myName) {
401
- continue;
402
- }
403
-
404
- if (!allowed || allowed.indexOf(name) < 0) {
405
- return true;
406
- }
407
- }
408
-
409
- return false;
410
- }
411
- }, {
412
- key: "getMapTouches",
413
- value: function getMapTouches(touches) {
414
- var mapTouches = [];
415
-
416
- var _iterator6 = _createForOfIteratorHelper(touches),
417
- _step6;
418
-
419
- try {
420
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
421
- var t = _step6.value;
422
- var target = t.target;
423
-
424
- if (this.el.contains(target)) {
425
- mapTouches.push(t);
426
- }
427
- }
428
- } catch (err) {
429
- _iterator6.e(err);
430
- } finally {
431
- _iterator6.f();
432
- }
433
-
434
- return mapTouches;
435
- }
436
- }, {
437
- key: "applyChanges",
438
- value: function applyChanges() {
439
- var combined = {};
440
- var combinedEventsInProgress = {};
441
- var combinedDeactivatedHandlers = {};
442
-
443
- var _iterator7 = _createForOfIteratorHelper(this.changes),
444
- _step7;
445
-
446
- try {
447
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
448
- var _step7$value = _slicedToArray(_step7.value, 3),
449
- change = _step7$value[0],
450
- eventsInProgress = _step7$value[1],
451
- deactivatedHandlers = _step7$value[2];
452
-
453
- if (change.panDelta) {
454
- combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);
455
- }
456
-
457
- if (change.zoomDelta) {
458
- combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;
459
- }
460
-
461
- if (change.bearingDelta) {
462
- combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;
463
- }
464
-
465
- if (change.pitchDelta) {
466
- combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;
467
- }
468
-
469
- if (change.around !== undefined) {
470
- combined.around = change.around;
471
- }
472
-
473
- if (change.pinchAround !== undefined) {
474
- combined.pinchAround = change.pinchAround;
475
- }
476
-
477
- if (change.noInertia) {
478
- combined.noInertia = change.noInertia;
479
- }
480
-
481
- merge(combinedEventsInProgress, eventsInProgress);
482
- merge(combinedDeactivatedHandlers, deactivatedHandlers);
483
- }
484
- } catch (err) {
485
- _iterator7.e(err);
486
- } finally {
487
- _iterator7.f();
488
- }
489
-
490
- this.updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);
491
- this.changes = [];
492
- }
493
- }, {
494
- key: "updateMapTransform",
495
- value: function updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) {
496
- var map = this.map;
497
- var tr = map.transform;
498
-
499
- if (!hasChange(combinedResult)) {
500
- return this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
501
- }
502
-
503
- var panDelta = combinedResult.panDelta,
504
- zoomDelta = combinedResult.zoomDelta,
505
- bearingDelta = combinedResult.bearingDelta,
506
- pitchDelta = combinedResult.pitchDelta,
507
- pinchAround = combinedResult.pinchAround;
508
- var around = combinedResult.around;
509
-
510
- if (pinchAround !== undefined) {
511
- around = pinchAround;
512
- }
513
-
514
- map.stop(true);
515
- around = around || map.transform.centerPoint;
516
- var loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);
517
-
518
- if (bearingDelta) {
519
- tr.bearing += bearingDelta;
520
- }
521
-
522
- if (pitchDelta) {
523
- tr.pitch += pitchDelta;
524
- }
525
-
526
- if (zoomDelta) {
527
- tr.zoom += zoomDelta;
528
- }
529
-
530
- tr.setLocationAtPoint(loc, around);
531
- this.map.update();
532
-
533
- if (!combinedResult.noInertia) {
534
- this.inertia.record(combinedResult);
535
- }
536
-
537
- this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
538
- }
539
- }, {
540
- key: "fireEvents",
541
- value: function fireEvents(newEventsInProgress, deactivatedHandlers) {
542
- var _this3 = this;
543
-
544
- var wasMoving = _isMoving(this.eventsInProgress);
545
-
546
- var nowMoving = _isMoving(newEventsInProgress);
547
-
548
- var startEvents = {};
549
-
550
- for (var eventName in newEventsInProgress) {
551
- if (newEventsInProgress[eventName]) {
552
- var originalEvent = newEventsInProgress[eventName].originalEvent;
553
-
554
- if (!this.eventsInProgress[eventName]) {
555
- startEvents["".concat(eventName, "start")] = originalEvent;
556
- }
557
-
558
- this.eventsInProgress[eventName] = newEventsInProgress[eventName];
559
- }
560
- }
561
-
562
- if (!wasMoving && nowMoving) {
563
- this.fireEvent('movestart', nowMoving.originalEvent);
564
- }
565
-
566
- for (var name in startEvents) {
567
- if (startEvents[name]) {
568
- this.fireEvent(name, startEvents[name]);
569
- }
570
- }
571
-
572
- if (newEventsInProgress.rotate) {
573
- this.bearingChanged = true;
574
- }
575
-
576
- if (nowMoving) {
577
- this.fireEvent('move', nowMoving.originalEvent);
578
- }
579
-
580
- for (var _eventName in newEventsInProgress) {
581
- if (newEventsInProgress[_eventName]) {
582
- var _originalEvent = newEventsInProgress[_eventName].originalEvent;
583
- this.fireEvent(_eventName, _originalEvent);
584
- }
585
- }
586
-
587
- var endEvents = {};
588
- var originalEndEvent;
589
-
590
- for (var _eventName2 in this.eventsInProgress) {
591
- if (this.eventsInProgress[_eventName2]) {
592
- var _this$eventsInProgres = this.eventsInProgress[_eventName2],
593
- handlerName = _this$eventsInProgres.handlerName,
594
- _originalEvent2 = _this$eventsInProgres.originalEvent;
595
-
596
- if (!this.handlersById[handlerName].isActive()) {
597
- delete this.eventsInProgress[_eventName2];
598
- originalEndEvent = deactivatedHandlers[handlerName] || _originalEvent2;
599
- endEvents["".concat(_eventName2, "end")] = originalEndEvent;
600
- }
601
- }
602
- }
603
-
604
- for (var _name in endEvents) {
605
- if (endEvents[_name]) {
606
- this.fireEvent(_name, endEvents[_name]);
607
- }
608
- }
609
-
610
- var stillMoving = _isMoving(this.eventsInProgress);
611
-
612
- if ((wasMoving || nowMoving) && !stillMoving) {
613
- this.updatingCamera = true;
614
- var inertialEase = this.inertia.onMoveEnd(this.map.dragPan.inertiaOptions);
615
-
616
- var shouldSnapToNorth = function shouldSnapToNorth(bearing) {
617
- return bearing !== 0 && -_this3.bearingSnap < bearing && bearing < _this3.bearingSnap;
618
- };
619
-
620
- if (inertialEase) {
621
- if (shouldSnapToNorth(inertialEase.bearing || this.map.getBearing())) {
622
- inertialEase.bearing = 0;
623
- }
624
-
625
- this.map.easeTo(inertialEase, {
626
- originalEvent: originalEndEvent
627
- });
628
- } else {
629
- this.map.emit('moveend', new Event('moveend', {
630
- originalEvent: originalEndEvent
631
- }));
632
-
633
- if (shouldSnapToNorth(this.map.getBearing())) {
634
- this.map.resetNorth();
635
- }
636
- }
637
-
638
- this.bearingChanged = false;
639
- this.updatingCamera = false;
640
- }
641
- }
642
- }, {
643
- key: "fireEvent",
644
- value: function fireEvent(type, e) {
645
- this.map.emit(type, new Event(type, e ? {
646
- originalEvent: e
647
- } : {}));
648
- }
649
- }]);
650
-
651
- return HandlerManager;
652
- }();
653
-
654
- export default HandlerManager;
655
- //# sourceMappingURL=handler_manager.js.map