@antv/l7-map 2.9.32-alpha.1 → 2.9.32-alpha.3

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 -84
  3. package/es/camera.js +0 -765
  4. package/es/css/l7.css +0 -98
  5. package/es/earthmap.d.ts +0 -66
  6. package/es/earthmap.js +0 -421
  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 -28
  14. package/es/geo/mercator.js +0 -91
  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 -28
  18. package/es/geo/simple.js +0 -90
  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 -129
  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 -134
  93. package/es/hash.d.ts +0 -14
  94. package/es/hash.js +0 -156
  95. package/es/index.d.ts +0 -3
  96. package/es/index.js +0 -3
  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 -463
  101. package/es/util.d.ts +0 -18
  102. package/es/util.js +0 -84
  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 -533
  114. package/lib/css/l7.css +0 -98
  115. package/lib/earthmap.js +0 -278
  116. package/lib/geo/edge_insets.js +0 -76
  117. package/lib/geo/lng_lat.js +0 -73
  118. package/lib/geo/lng_lat_bounds.js +0 -138
  119. package/lib/geo/mercator.js +0 -91
  120. package/lib/geo/point.js +0 -176
  121. package/lib/geo/simple.js +0 -87
  122. package/lib/geo/transform.js +0 -503
  123. package/lib/handler/IHandler.js +0 -17
  124. package/lib/handler/blockable_map_event.js +0 -71
  125. package/lib/handler/box_zoom.js +0 -139
  126. package/lib/handler/click_zoom.js +0 -59
  127. package/lib/handler/events/event.js +0 -38
  128. package/lib/handler/events/index.js +0 -38
  129. package/lib/handler/events/map_mouse_event.js +0 -44
  130. package/lib/handler/events/map_touch_event.js +0 -48
  131. package/lib/handler/events/map_wheel_event.js +0 -36
  132. package/lib/handler/events/render_event.js +0 -33
  133. package/lib/handler/handler_inertia.js +0 -149
  134. package/lib/handler/handler_manager.js +0 -455
  135. package/lib/handler/handler_util.js +0 -35
  136. package/lib/handler/keyboard.js +0 -131
  137. package/lib/handler/map_event.js +0 -91
  138. package/lib/handler/mouse/index.js +0 -38
  139. package/lib/handler/mouse/mouse_handler.js +0 -103
  140. package/lib/handler/mouse/mousepan_handler.js +0 -48
  141. package/lib/handler/mouse/mousepitch_hander.js +0 -47
  142. package/lib/handler/mouse/mouserotate_hander.js +0 -47
  143. package/lib/handler/mouse/util.js +0 -44
  144. package/lib/handler/scroll_zoom.js +0 -225
  145. package/lib/handler/shim/dblclick_zoom.js +0 -46
  146. package/lib/handler/shim/drag_pan.js +0 -55
  147. package/lib/handler/shim/drag_rotate.js +0 -49
  148. package/lib/handler/shim/touch_zoom_rotate.js +0 -71
  149. package/lib/handler/tap/single_tap_recognizer.js +0 -102
  150. package/lib/handler/tap/tap_drag_zoom.js +0 -106
  151. package/lib/handler/tap/tap_recognizer.js +0 -66
  152. package/lib/handler/tap/tap_zoom.js +0 -99
  153. package/lib/handler/touch/index.js +0 -41
  154. package/lib/handler/touch/touch_pan.js +0 -110
  155. package/lib/handler/touch/touch_pitch.js +0 -86
  156. package/lib/handler/touch/touch_rotate.js +0 -65
  157. package/lib/handler/touch/touch_zoom.js +0 -56
  158. package/lib/handler/touch/two_touch.js +0 -105
  159. package/lib/hash.js +0 -120
  160. package/lib/index.js +0 -21
  161. package/lib/interface.js +0 -17
  162. package/lib/map.js +0 -308
  163. package/lib/util.js +0 -97
  164. package/lib/utils/Aabb.js +0 -90
  165. package/lib/utils/dom.js +0 -159
  166. package/lib/utils/performance.js +0 -80
  167. package/lib/utils/primitives.js +0 -63
  168. package/lib/utils/task_queue.js +0 -72
@@ -1,455 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/handler/handler_manager.ts
23
- var handler_manager_exports = {};
24
- __export(handler_manager_exports, {
25
- default: () => handler_manager_default
26
- });
27
- module.exports = __toCommonJS(handler_manager_exports);
28
- var import_l7_utils = require("@antv/l7-utils");
29
- var import_lodash = require("lodash");
30
- var import_point = __toESM(require("../geo/point"));
31
- var import_dom = __toESM(require("../utils/dom"));
32
- var import_blockable_map_event = __toESM(require("./blockable_map_event"));
33
- var import_box_zoom = __toESM(require("./box_zoom"));
34
- var import_click_zoom = __toESM(require("./click_zoom"));
35
- var import_event = require("./events/event");
36
- var import_render_event = __toESM(require("./events/render_event"));
37
- var import_handler_inertia = __toESM(require("./handler_inertia"));
38
- var import_keyboard = __toESM(require("./keyboard"));
39
- var import_map_event = __toESM(require("./map_event"));
40
- var import_mouse = require("./mouse");
41
- var import_scroll_zoom = __toESM(require("./scroll_zoom"));
42
- var import_dblclick_zoom = __toESM(require("./shim/dblclick_zoom"));
43
- var import_drag_pan = __toESM(require("./shim/drag_pan"));
44
- var import_drag_rotate = __toESM(require("./shim/drag_rotate"));
45
- var import_touch_zoom_rotate = __toESM(require("./shim/touch_zoom_rotate"));
46
- var import_tap_drag_zoom = __toESM(require("./tap/tap_drag_zoom"));
47
- var import_tap_zoom = __toESM(require("./tap/tap_zoom"));
48
- var import_touch = require("./touch");
49
- var isMoving = (p) => p.zoom || p.drag || p.pitch || p.rotate;
50
- function hasChange(result) {
51
- return result.panDelta && result.panDelta.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta;
52
- }
53
- var HandlerManager = class {
54
- constructor(map, options) {
55
- this.handleWindowEvent = (e) => {
56
- this.handleEvent(e, `${e.type}Window`);
57
- };
58
- this.handleEvent = (e, eventName) => {
59
- if (e.type === "blur") {
60
- this.stop();
61
- return;
62
- }
63
- this.updatingCamera = true;
64
- const inputEvent = e.type === "renderFrame" ? void 0 : e;
65
- const mergedIHandlerResult = { needsRenderFrame: false };
66
- const eventsInProgress = {};
67
- const activeHandlers = {};
68
- const mapTouches = e.touches ? this.getMapTouches(e.touches) : void 0;
69
- const points = mapTouches ? import_dom.default.touchPos(this.el, mapTouches) : import_dom.default.mousePos(this.el, e);
70
- for (const { handlerName, handler, allowed } of this.handlers) {
71
- if (!handler.isEnabled()) {
72
- continue;
73
- }
74
- let data;
75
- if (this.blockedByActive(activeHandlers, allowed, handlerName)) {
76
- handler.reset();
77
- } else {
78
- const handerName = eventName || e.type;
79
- if (handler && handler[handerName]) {
80
- data = handler[handerName](e, points, mapTouches);
81
- this.mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, data, handlerName, inputEvent);
82
- if (data && data.needsRenderFrame) {
83
- this.triggerRenderFrame();
84
- }
85
- }
86
- }
87
- if (data || handler.isActive()) {
88
- activeHandlers[handlerName] = handler;
89
- }
90
- }
91
- const deactivatedHandlers = {};
92
- for (const name in this.previousActiveHandlers) {
93
- if (!activeHandlers[name]) {
94
- deactivatedHandlers[name] = inputEvent;
95
- }
96
- }
97
- this.previousActiveHandlers = activeHandlers;
98
- if (Object.keys(deactivatedHandlers).length || hasChange(mergedIHandlerResult)) {
99
- this.changes.push([
100
- mergedIHandlerResult,
101
- eventsInProgress,
102
- deactivatedHandlers
103
- ]);
104
- this.triggerRenderFrame();
105
- }
106
- if (Object.keys(activeHandlers).length || hasChange(mergedIHandlerResult)) {
107
- this.map.stop(true);
108
- }
109
- this.updatingCamera = false;
110
- const { cameraAnimation } = mergedIHandlerResult;
111
- if (cameraAnimation) {
112
- this.inertia.clear();
113
- this.fireEvents({}, {});
114
- this.changes = [];
115
- cameraAnimation(this.map);
116
- }
117
- };
118
- this.map = map;
119
- this.el = this.map.getCanvasContainer();
120
- this.handlers = [];
121
- this.handlersById = {};
122
- this.changes = [];
123
- this.inertia = new import_handler_inertia.default(map);
124
- this.bearingSnap = options.bearingSnap;
125
- this.rotateEnabled = options.rotateEnabled;
126
- this.pitchEnabled = options.pitchEnabled;
127
- this.previousActiveHandlers = {};
128
- this.eventsInProgress = {};
129
- this.addDefaultHandlers(options);
130
- const el = this.el;
131
- this.listeners = [];
132
- if (!import_l7_utils.isMini) {
133
- this.listeners = [
134
- [el, "touchstart", { passive: false }],
135
- [el, "touchmove", { passive: false }],
136
- [el, "touchend", void 0],
137
- [el, "touchcancel", void 0],
138
- [el, "mousedown", void 0],
139
- [el, "mousemove", void 0],
140
- [el, "mouseup", void 0],
141
- [window.document, "mousemove", { capture: true }],
142
- [window.document, "mouseup", void 0],
143
- [el, "mouseover", void 0],
144
- [el, "mouseout", void 0],
145
- [el, "dblclick", void 0],
146
- [el, "click", void 0],
147
- [el, "keydown", { capture: false }],
148
- [el, "keyup", void 0],
149
- [el, "wheel", { passive: false }],
150
- [el, "contextmenu", void 0],
151
- [window, "blur", void 0]
152
- ];
153
- for (const [target, type, listenerOptions] of this.listeners) {
154
- import_dom.default.addEventListener(target, type, target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
155
- }
156
- } else {
157
- import_l7_utils.$window.document.addEventListener("touchstart", (e) => {
158
- this.handleEvent(e);
159
- }, {});
160
- import_l7_utils.$window.document.addEventListener("touchmove", (e) => {
161
- this.handleEvent(e);
162
- }, {});
163
- import_l7_utils.$window.document.addEventListener("touchend", (e) => {
164
- this.handleEvent(e);
165
- }, {});
166
- import_l7_utils.$window.document.addEventListener("touchcancel", (e) => {
167
- this.handleEvent(e);
168
- }, {});
169
- }
170
- }
171
- destroy() {
172
- for (const [target, type, listenerOptions] of this.listeners) {
173
- import_dom.default.removeEventListener(target, type, target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
174
- }
175
- }
176
- stop() {
177
- if (this.updatingCamera) {
178
- return;
179
- }
180
- for (const { handler } of this.handlers) {
181
- handler.reset();
182
- }
183
- this.inertia.clear();
184
- this.fireEvents({}, {});
185
- this.changes = [];
186
- }
187
- isActive() {
188
- for (const { handler } of this.handlers) {
189
- if (handler.isActive()) {
190
- return true;
191
- }
192
- }
193
- return false;
194
- }
195
- isZooming() {
196
- return !!this.eventsInProgress.zoom || this.map.scrollZoom.isZooming();
197
- }
198
- isRotating() {
199
- return !!this.eventsInProgress.rotate;
200
- }
201
- isMoving() {
202
- return Boolean(isMoving(this.eventsInProgress)) || this.isZooming();
203
- }
204
- mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, HandlerResult, name, e) {
205
- if (!HandlerResult) {
206
- return;
207
- }
208
- (0, import_lodash.merge)(mergedIHandlerResult, HandlerResult);
209
- const eventData = {
210
- handlerName: name,
211
- originalEvent: HandlerResult.originalEvent || e
212
- };
213
- if (HandlerResult.zoomDelta !== void 0) {
214
- eventsInProgress.zoom = eventData;
215
- }
216
- if (HandlerResult.panDelta !== void 0) {
217
- eventsInProgress.drag = eventData;
218
- }
219
- if (HandlerResult.pitchDelta !== void 0) {
220
- eventsInProgress.pitch = eventData;
221
- }
222
- if (HandlerResult.bearingDelta !== void 0) {
223
- eventsInProgress.rotate = eventData;
224
- }
225
- }
226
- triggerRenderFrame() {
227
- if (this.frameId === void 0) {
228
- this.frameId = this.map.requestRenderFrame((timeStamp) => {
229
- delete this.frameId;
230
- this.handleEvent(new import_render_event.default("renderFrame", { timeStamp }));
231
- this.applyChanges();
232
- });
233
- }
234
- }
235
- addDefaultHandlers(options) {
236
- const map = this.map;
237
- const el = map.getCanvasContainer();
238
- this.add("mapEvent", new import_map_event.default(map, options));
239
- const boxZoom = map.boxZoom = new import_box_zoom.default(map, options);
240
- this.add("boxZoom", boxZoom);
241
- const tapZoom = new import_tap_zoom.default();
242
- const clickZoom = new import_click_zoom.default();
243
- map.doubleClickZoom = new import_dblclick_zoom.default(clickZoom, tapZoom);
244
- this.add("tapZoom", tapZoom);
245
- this.add("clickZoom", clickZoom);
246
- const tapDragZoom = new import_tap_drag_zoom.default();
247
- this.add("tapDragZoom", tapDragZoom);
248
- const touchPitch = map.touchPitch = new import_touch.TouchPitchHandler();
249
- this.add("touchPitch", touchPitch);
250
- const mouseRotate = new import_mouse.MouseRotateHandler(options);
251
- const mousePitch = new import_mouse.MousePitchHandler(options);
252
- map.dragRotate = new import_drag_rotate.default(options, mouseRotate, mousePitch);
253
- this.add("mouseRotate", mouseRotate, ["mousePitch"]);
254
- this.add("mousePitch", mousePitch, ["mouseRotate"]);
255
- const mousePan = new import_mouse.MousePanHandler(options);
256
- const touchPan = new import_touch.TouchPanHandler(options);
257
- map.dragPan = new import_drag_pan.default(el, mousePan, touchPan);
258
- this.add("mousePan", mousePan);
259
- this.add("touchPan", touchPan, ["touchZoom", "touchRotate"]);
260
- const touchRotate = new import_touch.TouchRotateHandler();
261
- const touchZoom = new import_touch.TouchZoomHandler();
262
- map.touchZoomRotate = new import_touch_zoom_rotate.default(el, touchZoom, touchRotate, tapDragZoom);
263
- this.add("touchRotate", touchRotate, ["touchPan", "touchZoom"]);
264
- this.add("touchZoom", touchZoom, ["touchPan", "touchRotate"]);
265
- const scrollZoom = map.scrollZoom = new import_scroll_zoom.default(map, this);
266
- this.add("scrollZoom", scrollZoom, ["mousePan"]);
267
- const keyboard = map.keyboard = new import_keyboard.default();
268
- this.add("keyboard", keyboard);
269
- this.add("blockableMapEvent", new import_blockable_map_event.default(map));
270
- for (const name of [
271
- "boxZoom",
272
- "doubleClickZoom",
273
- "tapDragZoom",
274
- "touchPitch",
275
- "dragRotate",
276
- "dragPan",
277
- "touchZoomRotate",
278
- "scrollZoom",
279
- "keyboard"
280
- ]) {
281
- if (options.interactive && options[name]) {
282
- map[name].enable(options[name]);
283
- }
284
- }
285
- }
286
- add(handlerName, handler, allowed) {
287
- this.handlers.push({ handlerName, handler, allowed });
288
- this.handlersById[handlerName] = handler;
289
- }
290
- blockedByActive(activeHandlers, allowed, myName) {
291
- for (const name in activeHandlers) {
292
- if (name === myName) {
293
- continue;
294
- }
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 (import_l7_utils.isMini || this.el.contains(target)) {
306
- mapTouches.push(t);
307
- }
308
- }
309
- return mapTouches;
310
- }
311
- applyChanges() {
312
- const combined = {};
313
- const combinedEventsInProgress = {};
314
- const combinedDeactivatedHandlers = {};
315
- for (const [change, eventsInProgress, deactivatedHandlers] of this.changes) {
316
- if (change.panDelta) {
317
- combined.panDelta = (combined.panDelta || new import_point.default(0, 0))._add(change.panDelta);
318
- }
319
- if (change.zoomDelta) {
320
- combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;
321
- }
322
- if (change.bearingDelta) {
323
- combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;
324
- }
325
- if (change.pitchDelta) {
326
- combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;
327
- }
328
- if (change.around !== void 0) {
329
- combined.around = change.around;
330
- }
331
- if (change.pinchAround !== void 0) {
332
- combined.pinchAround = change.pinchAround;
333
- }
334
- if (change.noInertia) {
335
- combined.noInertia = change.noInertia;
336
- }
337
- (0, import_lodash.merge)(combinedEventsInProgress, eventsInProgress);
338
- (0, import_lodash.merge)(combinedDeactivatedHandlers, deactivatedHandlers);
339
- }
340
- this.updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);
341
- this.changes = [];
342
- }
343
- updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) {
344
- const map = this.map;
345
- const tr = map.transform;
346
- if (!hasChange(combinedResult)) {
347
- return this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
348
- }
349
- const {
350
- panDelta,
351
- zoomDelta,
352
- bearingDelta,
353
- pitchDelta,
354
- pinchAround
355
- } = combinedResult;
356
- let { around } = combinedResult;
357
- if (pinchAround !== void 0) {
358
- around = pinchAround;
359
- }
360
- map.stop(true);
361
- around = around || map.transform.centerPoint;
362
- const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);
363
- if (bearingDelta && this.rotateEnabled) {
364
- tr.bearing += bearingDelta;
365
- }
366
- if (pitchDelta && this.pitchEnabled) {
367
- tr.pitch += pitchDelta;
368
- }
369
- if (zoomDelta) {
370
- tr.zoom += zoomDelta;
371
- }
372
- tr.setLocationAtPoint(loc, around);
373
- this.map.update();
374
- if (!combinedResult.noInertia) {
375
- this.inertia.record(combinedResult);
376
- }
377
- this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
378
- }
379
- fireEvents(newEventsInProgress, deactivatedHandlers) {
380
- const wasMoving = isMoving(this.eventsInProgress);
381
- const nowMoving = isMoving(newEventsInProgress);
382
- const startEvents = {};
383
- for (const eventName in newEventsInProgress) {
384
- if (newEventsInProgress[eventName]) {
385
- const { originalEvent } = newEventsInProgress[eventName];
386
- if (!this.eventsInProgress[eventName]) {
387
- startEvents[`${eventName}start`] = originalEvent;
388
- }
389
- this.eventsInProgress[eventName] = newEventsInProgress[eventName];
390
- }
391
- }
392
- if (!wasMoving && nowMoving) {
393
- this.fireEvent("movestart", nowMoving.originalEvent);
394
- }
395
- for (const name in startEvents) {
396
- if (startEvents[name]) {
397
- this.fireEvent(name, startEvents[name]);
398
- }
399
- }
400
- if (newEventsInProgress.rotate) {
401
- this.bearingChanged = true;
402
- }
403
- if (nowMoving) {
404
- this.fireEvent("move", nowMoving.originalEvent);
405
- }
406
- for (const eventName in newEventsInProgress) {
407
- if (newEventsInProgress[eventName]) {
408
- const { originalEvent } = newEventsInProgress[eventName];
409
- this.fireEvent(eventName, originalEvent);
410
- }
411
- }
412
- const endEvents = {};
413
- let originalEndEvent;
414
- for (const eventName in this.eventsInProgress) {
415
- if (this.eventsInProgress[eventName]) {
416
- const { handlerName, originalEvent } = this.eventsInProgress[eventName];
417
- if (!this.handlersById[handlerName].isActive()) {
418
- delete this.eventsInProgress[eventName];
419
- originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;
420
- endEvents[`${eventName}end`] = originalEndEvent;
421
- }
422
- }
423
- }
424
- for (const name in endEvents) {
425
- if (endEvents[name]) {
426
- this.fireEvent(name, endEvents[name]);
427
- }
428
- }
429
- const stillMoving = isMoving(this.eventsInProgress);
430
- if ((wasMoving || nowMoving) && !stillMoving) {
431
- this.updatingCamera = true;
432
- const inertialEase = this.inertia.onMoveEnd(this.map.dragPan.inertiaOptions);
433
- const shouldSnapToNorth = (bearing) => bearing !== 0 && -this.bearingSnap < bearing && bearing < this.bearingSnap;
434
- if (inertialEase) {
435
- if (shouldSnapToNorth(inertialEase.bearing || this.map.getBearing())) {
436
- inertialEase.bearing = 0;
437
- }
438
- this.map.easeTo(inertialEase, { originalEvent: originalEndEvent });
439
- } else {
440
- this.map.emit("moveend", new import_event.Event("moveend", { originalEvent: originalEndEvent }));
441
- if (shouldSnapToNorth(this.map.getBearing())) {
442
- this.map.resetNorth();
443
- }
444
- }
445
- this.bearingChanged = false;
446
- this.updatingCamera = false;
447
- }
448
- }
449
- fireEvent(type, e) {
450
- this.map.emit(type, new import_event.Event(type, e ? { originalEvent: e } : {}));
451
- }
452
- };
453
- var handler_manager_default = HandlerManager;
454
- // Annotate the CommonJS export names for ESM import in node:
455
- 0 && (module.exports = {});
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/handler/handler_util.ts
20
- var handler_util_exports = {};
21
- __export(handler_util_exports, {
22
- indexTouches: () => indexTouches
23
- });
24
- module.exports = __toCommonJS(handler_util_exports);
25
- function indexTouches(touches, points) {
26
- const obj = {};
27
- for (let i = 0; i < touches.length; i++) {
28
- obj[touches[i].identifier] = points[i];
29
- }
30
- return obj;
31
- }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- indexTouches
35
- });
@@ -1,131 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/handler/keyboard.ts
20
- var keyboard_exports = {};
21
- __export(keyboard_exports, {
22
- default: () => keyboard_default
23
- });
24
- module.exports = __toCommonJS(keyboard_exports);
25
- var defaultOptions = {
26
- panStep: 100,
27
- bearingStep: 15,
28
- pitchStep: 10
29
- };
30
- var KeyboardHandler = class {
31
- constructor() {
32
- const stepOptions = defaultOptions;
33
- this.panStep = stepOptions.panStep;
34
- this.bearingStep = stepOptions.bearingStep;
35
- this.pitchStep = stepOptions.pitchStep;
36
- }
37
- reset() {
38
- this.active = false;
39
- }
40
- keydown(e) {
41
- if (e.altKey || e.ctrlKey || e.metaKey) {
42
- return;
43
- }
44
- let zoomDir = 0;
45
- let bearingDir = 0;
46
- let pitchDir = 0;
47
- let xDir = 0;
48
- let yDir = 0;
49
- switch (e.keyCode) {
50
- case 61:
51
- case 107:
52
- case 171:
53
- case 187:
54
- zoomDir = 1;
55
- break;
56
- case 189:
57
- case 109:
58
- case 173:
59
- zoomDir = -1;
60
- break;
61
- case 37:
62
- if (e.shiftKey) {
63
- bearingDir = -1;
64
- } else {
65
- e.preventDefault();
66
- xDir = -1;
67
- }
68
- break;
69
- case 39:
70
- if (e.shiftKey) {
71
- bearingDir = 1;
72
- } else {
73
- e.preventDefault();
74
- xDir = 1;
75
- }
76
- break;
77
- case 38:
78
- if (e.shiftKey) {
79
- pitchDir = 1;
80
- } else {
81
- e.preventDefault();
82
- yDir = -1;
83
- }
84
- break;
85
- case 40:
86
- if (e.shiftKey) {
87
- pitchDir = -1;
88
- } else {
89
- e.preventDefault();
90
- yDir = 1;
91
- }
92
- break;
93
- default:
94
- return;
95
- }
96
- return {
97
- cameraAnimation: (map) => {
98
- const zoom = map.getZoom();
99
- map.easeTo({
100
- duration: 300,
101
- easeId: "keyboardHandler",
102
- easing: easeOut,
103
- zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
104
- bearing: map.getBearing() + bearingDir * this.bearingStep,
105
- pitch: map.getPitch() + pitchDir * this.pitchStep,
106
- offset: [-xDir * this.panStep, -yDir * this.panStep],
107
- center: map.getCenter()
108
- }, { originalEvent: e });
109
- }
110
- };
111
- }
112
- enable() {
113
- this.enabled = true;
114
- }
115
- disable() {
116
- this.enabled = false;
117
- this.reset();
118
- }
119
- isEnabled() {
120
- return this.enabled;
121
- }
122
- isActive() {
123
- return this.active;
124
- }
125
- };
126
- function easeOut(t) {
127
- return t * (2 - t);
128
- }
129
- var keyboard_default = KeyboardHandler;
130
- // Annotate the CommonJS export names for ESM import in node:
131
- 0 && (module.exports = {});