@antv/l7-map 2.17.12 → 2.18.2

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