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