@antv/l7-map 2.25.5 → 2.25.7

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 (159) hide show
  1. package/package.json +2 -2
  2. package/es/index.d.ts +0 -5
  3. package/es/index.js +0 -4
  4. package/es/map/camera.d.ts +0 -690
  5. package/es/map/camera.js +0 -1138
  6. package/es/map/css/l7.css +0 -171
  7. package/es/map/events.d.ts +0 -384
  8. package/es/map/events.js +0 -231
  9. package/es/map/geo/edge_insets.d.ts +0 -97
  10. package/es/map/geo/edge_insets.js +0 -115
  11. package/es/map/geo/lng_lat.d.ts +0 -116
  12. package/es/map/geo/lng_lat.js +0 -159
  13. package/es/map/geo/lng_lat_bounds.d.ts +0 -217
  14. package/es/map/geo/lng_lat_bounds.js +0 -334
  15. package/es/map/geo/mercator_coordinate.d.ts +0 -113
  16. package/es/map/geo/mercator_coordinate.js +0 -142
  17. package/es/map/geo/transform.d.ts +0 -262
  18. package/es/map/geo/transform.js +0 -736
  19. package/es/map/handler/box_zoom.d.ts +0 -65
  20. package/es/map/handler/box_zoom.js +0 -145
  21. package/es/map/handler/click_zoom.d.ts +0 -24
  22. package/es/map/handler/click_zoom.js +0 -47
  23. package/es/map/handler/cooperative_gestures.d.ts +0 -40
  24. package/es/map/handler/cooperative_gestures.js +0 -94
  25. package/es/map/handler/drag_handler.d.ts +0 -88
  26. package/es/map/handler/drag_handler.js +0 -89
  27. package/es/map/handler/drag_move_state_manager.d.ts +0 -30
  28. package/es/map/handler/drag_move_state_manager.js +0 -94
  29. package/es/map/handler/handler_util.d.ts +0 -3
  30. package/es/map/handler/handler_util.js +0 -8
  31. package/es/map/handler/keyboard.d.ts +0 -88
  32. package/es/map/handler/keyboard.js +0 -197
  33. package/es/map/handler/map_event.d.ts +0 -46
  34. package/es/map/handler/map_event.js +0 -131
  35. package/es/map/handler/mouse.d.ts +0 -30
  36. package/es/map/handler/mouse.js +0 -85
  37. package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
  38. package/es/map/handler/one_finger_touch_drag.js +0 -39
  39. package/es/map/handler/scroll_zoom.d.ts +0 -102
  40. package/es/map/handler/scroll_zoom.js +0 -312
  41. package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
  42. package/es/map/handler/shim/dblclick_zoom.js +0 -60
  43. package/es/map/handler/shim/drag_pan.d.ts +0 -79
  44. package/es/map/handler/shim/drag_pan.js +0 -77
  45. package/es/map/handler/shim/drag_rotate.d.ts +0 -54
  46. package/es/map/handler/shim/drag_rotate.js +0 -66
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
  48. package/es/map/handler/shim/two_fingers_touch.js +0 -106
  49. package/es/map/handler/tap_drag_zoom.d.ts +0 -28
  50. package/es/map/handler/tap_drag_zoom.js +0 -92
  51. package/es/map/handler/tap_recognizer.d.ts +0 -35
  52. package/es/map/handler/tap_recognizer.js +0 -107
  53. package/es/map/handler/tap_zoom.d.ts +0 -28
  54. package/es/map/handler/tap_zoom.js +0 -87
  55. package/es/map/handler/touch_pan.d.ts +0 -40
  56. package/es/map/handler/touch_pan.js +0 -85
  57. package/es/map/handler/transform-provider.d.ts +0 -23
  58. package/es/map/handler/transform-provider.js +0 -35
  59. package/es/map/handler/two_fingers_touch.d.ts +0 -107
  60. package/es/map/handler/two_fingers_touch.js +0 -289
  61. package/es/map/handler_inertia.d.ts +0 -20
  62. package/es/map/handler_inertia.js +0 -128
  63. package/es/map/handler_manager.d.ts +0 -154
  64. package/es/map/handler_manager.js +0 -466
  65. package/es/map/map.d.ts +0 -637
  66. package/es/map/map.js +0 -984
  67. package/es/map/util/abort_error.d.ts +0 -15
  68. package/es/map/util/abort_error.js +0 -21
  69. package/es/map/util/browser.d.ts +0 -10
  70. package/es/map/util/browser.js +0 -30
  71. package/es/map/util/dom.d.ts +0 -30
  72. package/es/map/util/dom.js +0 -105
  73. package/es/map/util/evented.d.ts +0 -75
  74. package/es/map/util/evented.js +0 -158
  75. package/es/map/util/simpleMapCoord.d.ts +0 -31
  76. package/es/map/util/simpleMapCoord.js +0 -54
  77. package/es/map/util/task_queue.d.ts +0 -18
  78. package/es/map/util/task_queue.js +0 -54
  79. package/es/map/util/util.d.ts +0 -104
  80. package/es/map/util/util.js +0 -155
  81. package/lib/index.d.ts +0 -5
  82. package/lib/index.js +0 -33
  83. package/lib/map/camera.d.ts +0 -690
  84. package/lib/map/camera.js +0 -1145
  85. package/lib/map/css/l7.css +0 -171
  86. package/lib/map/events.d.ts +0 -384
  87. package/lib/map/events.js +0 -240
  88. package/lib/map/geo/edge_insets.d.ts +0 -97
  89. package/lib/map/geo/edge_insets.js +0 -122
  90. package/lib/map/geo/lng_lat.d.ts +0 -116
  91. package/lib/map/geo/lng_lat.js +0 -166
  92. package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
  93. package/lib/map/geo/lng_lat_bounds.js +0 -341
  94. package/lib/map/geo/mercator_coordinate.d.ts +0 -113
  95. package/lib/map/geo/mercator_coordinate.js +0 -157
  96. package/lib/map/geo/transform.d.ts +0 -262
  97. package/lib/map/geo/transform.js +0 -744
  98. package/lib/map/handler/box_zoom.d.ts +0 -65
  99. package/lib/map/handler/box_zoom.js +0 -153
  100. package/lib/map/handler/click_zoom.d.ts +0 -24
  101. package/lib/map/handler/click_zoom.js +0 -54
  102. package/lib/map/handler/cooperative_gestures.d.ts +0 -40
  103. package/lib/map/handler/cooperative_gestures.js +0 -101
  104. package/lib/map/handler/drag_handler.d.ts +0 -88
  105. package/lib/map/handler/drag_handler.js +0 -97
  106. package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
  107. package/lib/map/handler/drag_move_state_manager.js +0 -103
  108. package/lib/map/handler/handler_util.d.ts +0 -3
  109. package/lib/map/handler/handler_util.js +0 -14
  110. package/lib/map/handler/keyboard.d.ts +0 -88
  111. package/lib/map/handler/keyboard.js +0 -205
  112. package/lib/map/handler/map_event.d.ts +0 -46
  113. package/lib/map/handler/map_event.js +0 -140
  114. package/lib/map/handler/mouse.d.ts +0 -30
  115. package/lib/map/handler/mouse.js +0 -93
  116. package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
  117. package/lib/map/handler/one_finger_touch_drag.js +0 -47
  118. package/lib/map/handler/scroll_zoom.d.ts +0 -102
  119. package/lib/map/handler/scroll_zoom.js +0 -320
  120. package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
  121. package/lib/map/handler/shim/dblclick_zoom.js +0 -68
  122. package/lib/map/handler/shim/drag_pan.d.ts +0 -79
  123. package/lib/map/handler/shim/drag_pan.js +0 -85
  124. package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
  125. package/lib/map/handler/shim/drag_rotate.js +0 -74
  126. package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
  127. package/lib/map/handler/shim/two_fingers_touch.js +0 -114
  128. package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
  129. package/lib/map/handler/tap_drag_zoom.js +0 -99
  130. package/lib/map/handler/tap_recognizer.d.ts +0 -35
  131. package/lib/map/handler/tap_recognizer.js +0 -116
  132. package/lib/map/handler/tap_zoom.d.ts +0 -28
  133. package/lib/map/handler/tap_zoom.js +0 -94
  134. package/lib/map/handler/touch_pan.d.ts +0 -40
  135. package/lib/map/handler/touch_pan.js +0 -92
  136. package/lib/map/handler/transform-provider.d.ts +0 -23
  137. package/lib/map/handler/transform-provider.js +0 -43
  138. package/lib/map/handler/two_fingers_touch.d.ts +0 -107
  139. package/lib/map/handler/two_fingers_touch.js +0 -296
  140. package/lib/map/handler_inertia.d.ts +0 -20
  141. package/lib/map/handler_inertia.js +0 -136
  142. package/lib/map/handler_manager.d.ts +0 -154
  143. package/lib/map/handler_manager.js +0 -474
  144. package/lib/map/map.d.ts +0 -637
  145. package/lib/map/map.js +0 -991
  146. package/lib/map/util/abort_error.d.ts +0 -15
  147. package/lib/map/util/abort_error.js +0 -29
  148. package/lib/map/util/browser.d.ts +0 -10
  149. package/lib/map/util/browser.js +0 -36
  150. package/lib/map/util/dom.d.ts +0 -30
  151. package/lib/map/util/dom.js +0 -113
  152. package/lib/map/util/evented.d.ts +0 -75
  153. package/lib/map/util/evented.js +0 -167
  154. package/lib/map/util/simpleMapCoord.d.ts +0 -31
  155. package/lib/map/util/simpleMapCoord.js +0 -62
  156. package/lib/map/util/task_queue.d.ts +0 -18
  157. package/lib/map/util/task_queue.js +0 -62
  158. package/lib/map/util/util.d.ts +0 -104
  159. package/lib/map/util/util.js +0 -171
@@ -1,474 +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.HandlerManager = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
10
- var _box_zoom = require("./handler/box_zoom");
11
- var _click_zoom = require("./handler/click_zoom");
12
- var _cooperative_gestures = require("./handler/cooperative_gestures");
13
- var _keyboard = require("./handler/keyboard");
14
- var _map_event = require("./handler/map_event");
15
- var _mouse = require("./handler/mouse");
16
- var _scroll_zoom = require("./handler/scroll_zoom");
17
- var _dblclick_zoom = require("./handler/shim/dblclick_zoom");
18
- var _drag_pan = require("./handler/shim/drag_pan");
19
- var _drag_rotate = require("./handler/shim/drag_rotate");
20
- var _two_fingers_touch = require("./handler/shim/two_fingers_touch");
21
- var _tap_drag_zoom = require("./handler/tap_drag_zoom");
22
- var _tap_zoom = require("./handler/tap_zoom");
23
- var _touch_pan = require("./handler/touch_pan");
24
- var _two_fingers_touch2 = require("./handler/two_fingers_touch");
25
- var _handler_inertia = require("./handler_inertia");
26
- var _browser = require("./util/browser");
27
- var _dom = require("./util/dom");
28
- var _evented = require("./util/evented");
29
- var _util = require("./util/util");
30
- const isMoving = p => p.zoom || p.drag || p.pitch || p.rotate;
31
- class RenderFrameEvent extends _evented.Event {
32
- constructor(type, timeStamp) {
33
- super(type);
34
- (0, _defineProperty2.default)(this, "type", 'renderFrame');
35
- (0, _defineProperty2.default)(this, "timeStamp", void 0);
36
- this.timeStamp = timeStamp;
37
- }
38
- }
39
-
40
- /**
41
- * Handlers interpret dom events and return camera changes that should be
42
- * applied to the map (`HandlerResult`s). The camera changes are all deltas.
43
- * The handler itself should have no knowledge of the map's current state.
44
- * This makes it easier to merge multiple results and keeps handlers simpler.
45
- * For example, if there is a mousedown and mousemove, the mousePan handler
46
- * would return a `panDelta` on the mousemove.
47
- */
48
-
49
- /**
50
- * All handler methods that are called with events can optionally return a `HandlerResult`.
51
- */
52
-
53
- function hasChange(result) {
54
- return result.panDelta && result.panDelta.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta;
55
- }
56
- class HandlerManager {
57
- constructor(map, options) {
58
- (0, _defineProperty2.default)(this, "_map", void 0);
59
- (0, _defineProperty2.default)(this, "_el", void 0);
60
- (0, _defineProperty2.default)(this, "_handlers", void 0);
61
- (0, _defineProperty2.default)(this, "_eventsInProgress", void 0);
62
- (0, _defineProperty2.default)(this, "_frameId", void 0);
63
- (0, _defineProperty2.default)(this, "_inertia", void 0);
64
- (0, _defineProperty2.default)(this, "_bearingSnap", void 0);
65
- (0, _defineProperty2.default)(this, "_handlersById", void 0);
66
- (0, _defineProperty2.default)(this, "_updatingCamera", void 0);
67
- (0, _defineProperty2.default)(this, "_changes", void 0);
68
- (0, _defineProperty2.default)(this, "_zoom", void 0);
69
- (0, _defineProperty2.default)(this, "_previousActiveHandlers", void 0);
70
- (0, _defineProperty2.default)(this, "_listeners", void 0);
71
- (0, _defineProperty2.default)(this, "handleWindowEvent", e => {
72
- this.handleEvent(e, `${e.type}Window`);
73
- });
74
- (0, _defineProperty2.default)(this, "handleEvent", (e, eventName) => {
75
- if (e.type === 'blur') {
76
- this.stop(true);
77
- return;
78
- }
79
- this._updatingCamera = true;
80
- const inputEvent = e.type === 'renderFrame' ? undefined : e;
81
-
82
- /*
83
- * We don't call e.preventDefault() for any events by default.
84
- * Handlers are responsible for calling it where necessary.
85
- */
86
-
87
- const mergedHandlerResult = {
88
- needsRenderFrame: false
89
- };
90
- const eventsInProgress = {};
91
- const activeHandlers = {};
92
- const eventTouches = e.touches;
93
- const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined;
94
- const points = mapTouches ? _dom.DOM.touchPos(this._map.getCanvasContainer(), mapTouches) : _dom.DOM.mousePos(this._map.getCanvasContainer(), e);
95
- for (const {
96
- handlerName,
97
- handler,
98
- allowed
99
- } of this._handlers) {
100
- if (!handler.isEnabled()) continue;
101
- let data;
102
- if (this._blockedByActive(activeHandlers, allowed, handlerName)) {
103
- handler.reset();
104
- } else {
105
- if (handler[eventName || e.type]) {
106
- data = handler[eventName || e.type](e, points, mapTouches);
107
- this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);
108
- if (data && data.needsRenderFrame) {
109
- this._triggerRenderFrame();
110
- }
111
- }
112
- }
113
- if (data || handler.isActive()) {
114
- activeHandlers[handlerName] = handler;
115
- }
116
- }
117
- const deactivatedHandlers = {};
118
- for (const name in this._previousActiveHandlers) {
119
- if (!activeHandlers[name]) {
120
- deactivatedHandlers[name] = inputEvent;
121
- }
122
- }
123
- this._previousActiveHandlers = activeHandlers;
124
- if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) {
125
- this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]);
126
- this._triggerRenderFrame();
127
- }
128
- if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) {
129
- this._map._stop(true);
130
- }
131
- this._updatingCamera = false;
132
- const {
133
- cameraAnimation
134
- } = mergedHandlerResult;
135
- if (cameraAnimation) {
136
- this._inertia.clear();
137
- this._fireEvents({}, {}, true);
138
- this._changes = [];
139
- cameraAnimation(this._map);
140
- }
141
- });
142
- this._map = map;
143
- this._el = this._map.getCanvasContainer();
144
- this._handlers = [];
145
- this._handlersById = {};
146
- this._changes = [];
147
- this._inertia = new _handler_inertia.HandlerInertia(map);
148
- this._bearingSnap = options.bearingSnap || 7;
149
- this._previousActiveHandlers = {};
150
-
151
- // Track whether map is currently moving, to compute start/move/end events
152
- this._eventsInProgress = {};
153
- this._addDefaultHandlers(options);
154
- const el = this._el;
155
- this._listeners = [
156
- // This needs to be `passive: true` so that a double tap fires two
157
- // pairs of touchstart/end events in iOS Safari 13. If this is set to
158
- // `passive: false` then the second pair of events is only fired if
159
- // preventDefault() is called on the first touchstart. Calling preventDefault()
160
- // undesirably prevents click events.
161
- [el, 'touchstart', {
162
- passive: true
163
- }],
164
- // This needs to be `passive: false` so that scrolls and pinches can be
165
- // prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.
166
- [el, 'touchmove', {
167
- passive: false
168
- }], [el, 'touchend', undefined], [el, 'touchcancel', undefined], [el, 'mousedown', undefined], [el, 'mousemove', undefined], [el, 'mouseup', undefined],
169
- // Bind window-level event listeners for move and up/end events. In the absence of
170
- // the pointer capture API, which is not supported by all necessary platforms,
171
- // window-level event listeners give us the best shot at capturing events that
172
- // fall outside the map canvas element. Use `{capture: true}` for the move event
173
- // to prevent map move events from being fired during a drag.
174
- [document, 'mousemove', {
175
- capture: true
176
- }], [document, 'mouseup', undefined], [el, 'mouseover', undefined], [el, 'mouseout', undefined], [el, 'dblclick', undefined], [el, 'click', undefined], [el, 'keydown', {
177
- capture: false
178
- }], [el, 'keyup', undefined], [el, 'wheel', {
179
- passive: false
180
- }], [el, 'contextmenu', undefined], [window, 'blur', undefined]];
181
- for (const [target, type, listenerOptions] of this._listeners) {
182
- _dom.DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
183
- }
184
- }
185
- destroy() {
186
- for (const [target, type, listenerOptions] of this._listeners) {
187
- _dom.DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
188
- }
189
- }
190
- _addDefaultHandlers(options) {
191
- const map = this._map;
192
- const el = map.getCanvasContainer();
193
- this._add('mapEvent', new _map_event.MapEventHandler(map, options));
194
- const boxZoom = map.boxZoom = new _box_zoom.BoxZoomHandler(map, options);
195
- this._add('boxZoom', boxZoom);
196
- if (options.interactive && options.boxZoom) {
197
- boxZoom.enable();
198
- }
199
- const cooperativeGestures = map.cooperativeGestures = new _cooperative_gestures.CooperativeGesturesHandler(map, options.cooperativeGestures);
200
- this._add('cooperativeGestures', cooperativeGestures);
201
- if (options.cooperativeGestures) {
202
- cooperativeGestures.enable();
203
- }
204
- const tapZoom = new _tap_zoom.TapZoomHandler(map);
205
- const clickZoom = new _click_zoom.ClickZoomHandler(map);
206
- map.doubleClickZoom = new _dblclick_zoom.DoubleClickZoomHandler(clickZoom, tapZoom);
207
- this._add('tapZoom', tapZoom);
208
- this._add('clickZoom', clickZoom);
209
- if (options.interactive && options.doubleClickZoom) {
210
- map.doubleClickZoom.enable();
211
- }
212
- const tapDragZoom = new _tap_drag_zoom.TapDragZoomHandler();
213
- this._add('tapDragZoom', tapDragZoom);
214
- const touchPitch = map.touchPitch = new _two_fingers_touch2.TwoFingersTouchPitchHandler(map);
215
- this._add('touchPitch', touchPitch);
216
- if (options.interactive && options.touchPitch) {
217
- map.touchPitch.enable(options.touchPitch);
218
- }
219
- const mouseRotate = (0, _mouse.generateMouseRotationHandler)(options);
220
- const mousePitch = (0, _mouse.generateMousePitchHandler)(options);
221
- map.dragRotate = new _drag_rotate.DragRotateHandler(options, mouseRotate, mousePitch);
222
- this._add('mouseRotate', mouseRotate, ['mousePitch']);
223
- this._add('mousePitch', mousePitch, ['mouseRotate']);
224
- if (options.interactive && options.dragRotate) {
225
- map.dragRotate.enable();
226
- }
227
- const mousePan = (0, _mouse.generateMousePanHandler)(options);
228
- const touchPan = new _touch_pan.TouchPanHandler(options, map);
229
- map.dragPan = new _drag_pan.DragPanHandler(el, mousePan, touchPan);
230
- this._add('mousePan', mousePan);
231
- this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);
232
- if (options.interactive && options.dragPan) {
233
- map.dragPan.enable(options.dragPan);
234
- }
235
- const touchRotate = new _two_fingers_touch2.TwoFingersTouchRotateHandler();
236
- const touchZoom = new _two_fingers_touch2.TwoFingersTouchZoomHandler();
237
- map.touchZoomRotate = new _two_fingers_touch.TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);
238
- this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);
239
- this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);
240
- if (options.interactive && options.touchZoomRotate) {
241
- map.touchZoomRotate.enable(options.touchZoomRotate);
242
- }
243
- const scrollZoom = map.scrollZoom = new _scroll_zoom.ScrollZoomHandler(map, () => this._triggerRenderFrame());
244
- this._add('scrollZoom', scrollZoom, ['mousePan']);
245
- if (options.interactive && options.scrollZoom) {
246
- map.scrollZoom.enable(options.scrollZoom);
247
- }
248
- const keyboard = map.keyboard = new _keyboard.KeyboardHandler(map);
249
- this._add('keyboard', keyboard);
250
- if (options.interactive && options.keyboard) {
251
- map.keyboard.enable();
252
- }
253
- this._add('blockableMapEvent', new _map_event.BlockableMapEventHandler(map));
254
- }
255
- _add(handlerName, handler, allowed) {
256
- this._handlers.push({
257
- handlerName,
258
- handler,
259
- allowed
260
- });
261
- this._handlersById[handlerName] = handler;
262
- }
263
- stop(allowEndAnimation) {
264
- // do nothing if this method was triggered by a gesture update
265
- if (this._updatingCamera) return;
266
- for (const {
267
- handler
268
- } of this._handlers) {
269
- handler.reset();
270
- }
271
- this._inertia.clear();
272
- this._fireEvents({}, {}, allowEndAnimation);
273
- this._changes = [];
274
- }
275
- isActive() {
276
- for (const {
277
- handler
278
- } of this._handlers) {
279
- if (handler.isActive()) return true;
280
- }
281
- return false;
282
- }
283
- isZooming() {
284
- return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();
285
- }
286
- isRotating() {
287
- return !!this._eventsInProgress.rotate;
288
- }
289
- isMoving() {
290
- return Boolean(isMoving(this._eventsInProgress)) || this.isZooming();
291
- }
292
- _blockedByActive(activeHandlers, allowed, myName) {
293
- for (const name in activeHandlers) {
294
- if (name === myName) continue;
295
- if (!allowed || allowed.indexOf(name) < 0) {
296
- return true;
297
- }
298
- }
299
- return false;
300
- }
301
- _getMapTouches(touches) {
302
- const mapTouches = [];
303
- for (const t of touches) {
304
- const target = t.target;
305
- if (this._el.contains(target)) {
306
- mapTouches.push(t);
307
- }
308
- }
309
- return mapTouches;
310
- }
311
- mergeHandlerResult(mergedHandlerResult, eventsInProgress, handlerResult, name, e) {
312
- if (!handlerResult) return;
313
- (0, _util.extend)(mergedHandlerResult, handlerResult);
314
- const eventData = {
315
- handlerName: name,
316
- originalEvent: handlerResult.originalEvent || e
317
- };
318
-
319
- // track which handler changed which camera property
320
- if (handlerResult.zoomDelta !== undefined) {
321
- eventsInProgress.zoom = eventData;
322
- }
323
- if (handlerResult.panDelta !== undefined) {
324
- eventsInProgress.drag = eventData;
325
- }
326
- if (handlerResult.pitchDelta !== undefined) {
327
- eventsInProgress.pitch = eventData;
328
- }
329
- if (handlerResult.bearingDelta !== undefined) {
330
- eventsInProgress.rotate = eventData;
331
- }
332
- }
333
- _applyChanges() {
334
- const combined = {};
335
- const combinedEventsInProgress = {};
336
- const combinedDeactivatedHandlers = {};
337
- for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) {
338
- if (change.panDelta) combined.panDelta = (combined.panDelta || new _pointGeometry.default(0, 0))._add(change.panDelta);
339
- if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;
340
- if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;
341
- if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;
342
- if (change.around !== undefined) combined.around = change.around;
343
- if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround;
344
- if (change.noInertia) combined.noInertia = change.noInertia;
345
- (0, _util.extend)(combinedEventsInProgress, eventsInProgress);
346
- (0, _util.extend)(combinedDeactivatedHandlers, deactivatedHandlers);
347
- }
348
- this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);
349
- this._changes = [];
350
- }
351
- _updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) {
352
- const map = this._map;
353
- const tr = map._getTransformForUpdate();
354
- if (!hasChange(combinedResult)) {
355
- return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);
356
- }
357
- const {
358
- panDelta,
359
- zoomDelta,
360
- bearingDelta,
361
- pitchDelta,
362
- pinchAround
363
- } = combinedResult;
364
- let {
365
- around
366
- } = combinedResult;
367
- if (pinchAround !== undefined) {
368
- around = pinchAround;
369
- }
370
-
371
- // stop any ongoing camera animations (easeTo, flyTo)
372
- map._stop(true);
373
- around = around || map.transform.centerPoint;
374
- const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);
375
- if (bearingDelta) tr.bearing += bearingDelta;
376
- if (pitchDelta) tr.pitch += pitchDelta;
377
- if (zoomDelta) tr.zoom += zoomDelta;
378
- tr.setLocationAtPoint(loc, around);
379
- map._applyUpdatedTransform(tr);
380
- this._map._update();
381
- if (!combinedResult.noInertia) this._inertia.record(combinedResult);
382
- this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);
383
- }
384
- _fireEvents(newEventsInProgress, deactivatedHandlers, allowEndAnimation) {
385
- const wasMoving = isMoving(this._eventsInProgress);
386
- const nowMoving = isMoving(newEventsInProgress);
387
- const startEvents = {};
388
- for (const eventName in newEventsInProgress) {
389
- const {
390
- originalEvent
391
- } = newEventsInProgress[eventName];
392
- if (!this._eventsInProgress[eventName]) {
393
- startEvents[`${eventName}start`] = originalEvent;
394
- }
395
- this._eventsInProgress[eventName] = newEventsInProgress[eventName];
396
- }
397
-
398
- // fire start events only after this._eventsInProgress has been updated
399
- if (!wasMoving && nowMoving) {
400
- this._fireEvent('movestart', nowMoving.originalEvent);
401
- }
402
- for (const name in startEvents) {
403
- this._fireEvent(name, startEvents[name]);
404
- }
405
- if (nowMoving) {
406
- this._fireEvent('move', nowMoving.originalEvent);
407
- }
408
- for (const eventName in newEventsInProgress) {
409
- const {
410
- originalEvent
411
- } = newEventsInProgress[eventName];
412
- this._fireEvent(eventName, originalEvent);
413
- }
414
- const endEvents = {};
415
- let originalEndEvent;
416
- for (const eventName in this._eventsInProgress) {
417
- const {
418
- handlerName,
419
- originalEvent
420
- } = this._eventsInProgress[eventName];
421
- if (!this._handlersById[handlerName].isActive()) {
422
- delete this._eventsInProgress[eventName];
423
- originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;
424
- endEvents[`${eventName}end`] = originalEndEvent;
425
- }
426
- }
427
- for (const name in endEvents) {
428
- this._fireEvent(name, endEvents[name]);
429
- }
430
- const stillMoving = isMoving(this._eventsInProgress);
431
- const finishedMoving = (wasMoving || nowMoving) && !stillMoving;
432
- if (allowEndAnimation && finishedMoving) {
433
- this._updatingCamera = true;
434
- const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);
435
- const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;
436
- if (inertialEase && (inertialEase.essential || !_browser.browser.prefersReducedMotion)) {
437
- if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {
438
- inertialEase.bearing = 0;
439
- }
440
- inertialEase.freezeElevation = true;
441
- this._map.easeTo(inertialEase, {
442
- originalEvent: originalEndEvent
443
- });
444
- } else {
445
- this._map.fire(new _evented.Event('moveend', {
446
- originalEvent: originalEndEvent
447
- }));
448
- if (shouldSnapToNorth(this._map.getBearing())) {
449
- this._map.resetNorth();
450
- }
451
- }
452
- this._updatingCamera = false;
453
- }
454
- }
455
- _fireEvent(type, e) {
456
- this._map.fire(new _evented.Event(type, e ? {
457
- originalEvent: e
458
- } : {}));
459
- }
460
- _requestFrame() {
461
- this._map.triggerRepaint();
462
- return this._map._renderTaskQueue.add(timeStamp => {
463
- delete this._frameId;
464
- this.handleEvent(new RenderFrameEvent('renderFrame', timeStamp));
465
- this._applyChanges();
466
- });
467
- }
468
- _triggerRenderFrame() {
469
- if (this._frameId === undefined) {
470
- this._frameId = this._requestFrame();
471
- }
472
- }
473
- }
474
- exports.HandlerManager = HandlerManager;