@antv/l7-map 2.15.2 → 2.15.4

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 (103) hide show
  1. package/es/camera.js +90 -148
  2. package/es/earthmap.js +13 -65
  3. package/es/geo/edge_insets.js +4 -14
  4. package/es/geo/lng_lat.js +5 -13
  5. package/es/geo/lng_lat_bounds.js +4 -17
  6. package/es/geo/mercator.js +2 -10
  7. package/es/geo/point.js +0 -7
  8. package/es/geo/simple.js +6 -11
  9. package/es/geo/transform.js +123 -132
  10. package/es/handler/blockable_map_event.js +7 -12
  11. package/es/handler/box_zoom.js +10 -30
  12. package/es/handler/click_zoom.js +0 -5
  13. package/es/handler/events/event.js +0 -2
  14. package/es/handler/events/map_mouse_event.js +0 -12
  15. package/es/handler/events/map_touch_event.js +2 -12
  16. package/es/handler/events/map_wheel_event.js +1 -12
  17. package/es/handler/events/render_event.js +0 -13
  18. package/es/handler/handler_inertia.js +6 -34
  19. package/es/handler/handler_manager.js +55 -147
  20. package/es/handler/handler_util.js +1 -2
  21. package/es/handler/keyboard.js +1 -20
  22. package/es/handler/map_event.js +3 -9
  23. package/es/handler/mouse/mouse_handler.js +11 -24
  24. package/es/handler/mouse/mousepan_handler.js +1 -11
  25. package/es/handler/mouse/mousepitch_hander.js +1 -11
  26. package/es/handler/mouse/mouserotate_hander.js +1 -11
  27. package/es/handler/mouse/util.js +2 -3
  28. package/es/handler/scroll_zoom.js +43 -71
  29. package/es/handler/shim/dblclick_zoom.js +4 -9
  30. package/es/handler/shim/drag_pan.js +4 -11
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +6 -16
  33. package/es/handler/tap/single_tap_recognizer.js +8 -31
  34. package/es/handler/tap/tap_drag_zoom.js +7 -15
  35. package/es/handler/tap/tap_recognizer.js +3 -11
  36. package/es/handler/tap/tap_zoom.js +1 -7
  37. package/es/handler/touch/touch_pan.js +4 -22
  38. package/es/handler/touch/touch_pitch.js +10 -27
  39. package/es/handler/touch/touch_rotate.js +8 -19
  40. package/es/handler/touch/touch_zoom.js +5 -18
  41. package/es/handler/touch/two_touch.js +19 -32
  42. package/es/hash.js +9 -31
  43. package/es/map.js +16 -78
  44. package/es/util.js +18 -23
  45. package/es/utils/Aabb.js +10 -31
  46. package/es/utils/dom.js +24 -58
  47. package/es/utils/performance.js +8 -7
  48. package/es/utils/primitives.js +13 -11
  49. package/es/utils/task_queue.js +6 -23
  50. package/lib/camera.js +90 -168
  51. package/lib/earthmap.js +11 -79
  52. package/lib/geo/edge_insets.js +3 -18
  53. package/lib/geo/lng_lat.js +5 -18
  54. package/lib/geo/lng_lat_bounds.js +4 -20
  55. package/lib/geo/mercator.js +1 -22
  56. package/lib/geo/point.js +0 -8
  57. package/lib/geo/simple.js +5 -24
  58. package/lib/geo/transform.js +123 -164
  59. package/lib/handler/blockable_map_event.js +6 -14
  60. package/lib/handler/box_zoom.js +8 -39
  61. package/lib/handler/click_zoom.js +0 -6
  62. package/lib/handler/events/event.js +0 -5
  63. package/lib/handler/events/index.js +0 -4
  64. package/lib/handler/events/map_mouse_event.js +0 -19
  65. package/lib/handler/events/map_touch_event.js +1 -20
  66. package/lib/handler/events/map_wheel_event.js +1 -16
  67. package/lib/handler/events/render_event.js +0 -19
  68. package/lib/handler/handler_inertia.js +4 -37
  69. package/lib/handler/handler_manager.js +55 -171
  70. package/lib/handler/handler_util.js +1 -3
  71. package/lib/handler/keyboard.js +1 -22
  72. package/lib/handler/map_event.js +2 -11
  73. package/lib/handler/mouse/index.js +0 -4
  74. package/lib/handler/mouse/mouse_handler.js +10 -27
  75. package/lib/handler/mouse/mousepan_handler.js +0 -17
  76. package/lib/handler/mouse/mousepitch_hander.js +0 -16
  77. package/lib/handler/mouse/mouserotate_hander.js +0 -16
  78. package/lib/handler/mouse/util.js +2 -6
  79. package/lib/handler/scroll_zoom.js +43 -77
  80. package/lib/handler/shim/dblclick_zoom.js +4 -10
  81. package/lib/handler/shim/drag_pan.js +4 -13
  82. package/lib/handler/shim/drag_rotate.js +4 -11
  83. package/lib/handler/shim/touch_zoom_rotate.js +6 -18
  84. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  85. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  86. package/lib/handler/tap/tap_recognizer.js +2 -17
  87. package/lib/handler/tap/tap_zoom.js +0 -9
  88. package/lib/handler/touch/index.js +0 -5
  89. package/lib/handler/touch/touch_pan.js +4 -25
  90. package/lib/handler/touch/touch_pitch.js +9 -31
  91. package/lib/handler/touch/touch_rotate.js +7 -24
  92. package/lib/handler/touch/touch_zoom.js +4 -23
  93. package/lib/handler/touch/two_touch.js +18 -35
  94. package/lib/hash.js +8 -35
  95. package/lib/index.js +0 -8
  96. package/lib/map.js +14 -94
  97. package/lib/util.js +16 -34
  98. package/lib/utils/Aabb.js +10 -34
  99. package/lib/utils/dom.js +22 -64
  100. package/lib/utils/performance.js +8 -9
  101. package/lib/utils/primitives.js +13 -16
  102. package/lib/utils/task_queue.js +6 -24
  103. package/package.json +3 -3
package/es/camera.js CHANGED
@@ -5,11 +5,8 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
-
9
8
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
10
  // @ts-ignore
14
11
  import { EventEmitter } from 'eventemitter3';
15
12
  import { merge } from 'lodash';
@@ -19,26 +16,19 @@ import Point from "./geo/point";
19
16
  import Transform from "./geo/transform";
20
17
  import { Event } from "./handler/events/event";
21
18
  import { clamp, ease as defaultEasing, interpolate, now, pick, prefersReducedMotion, wrap } from "./util";
22
-
23
19
  var Camera = /*#__PURE__*/function (_EventEmitter) {
24
20
  _inherits(Camera, _EventEmitter);
25
-
26
21
  var _super = _createSuper(Camera);
27
-
28
22
  // public requestRenderFrame: (_: any) => number;
29
23
  // public cancelRenderFrame: (_: number) => void;
24
+
30
25
  function Camera(options) {
31
26
  var _this;
32
-
33
27
  _classCallCheck(this, Camera);
34
-
35
28
  _this = _super.call(this);
36
-
37
29
  _defineProperty(_assertThisInitialized(_this), "renderFrameCallback", function () {
38
30
  var t = Math.min((now() - _this.easeStart) / _this.easeOptions.duration, 1);
39
-
40
31
  _this.onEaseFrame(_this.easeOptions.easing(t));
41
-
42
32
  if (t < 1) {
43
33
  // this.easeFrameId = window.requestAnimationFrame(this.renderFrameCallback);
44
34
  _this.easeFrameId = _this.requestRenderFrame(_this.renderFrameCallback);
@@ -46,13 +36,12 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
46
36
  _this.stop();
47
37
  }
48
38
  });
49
-
50
39
  _this.options = options;
51
40
  var minZoom = options.minZoom,
52
- maxZoom = options.maxZoom,
53
- minPitch = options.minPitch,
54
- maxPitch = options.maxPitch,
55
- renderWorldCopies = options.renderWorldCopies;
41
+ maxZoom = options.maxZoom,
42
+ minPitch = options.minPitch,
43
+ maxPitch = options.maxPitch,
44
+ renderWorldCopies = options.renderWorldCopies;
56
45
  _this.moving = false;
57
46
  _this.zooming = false;
58
47
  _this.bearingSnap = options.bearingSnap;
@@ -60,15 +49,14 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
60
49
  _this.rotateEnabled = options.rotateEnabled;
61
50
  _this.transform = new Transform(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
62
51
  return _this;
63
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
-
65
-
52
+ }
53
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
54
  _createClass(Camera, [{
67
55
  key: "requestRenderFrame",
68
56
  value: function requestRenderFrame(cb) {
69
57
  return 0;
70
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
-
58
+ }
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
60
  }, {
73
61
  key: "cancelRenderFrame",
74
62
  value: function cancelRenderFrame(_) {
@@ -78,8 +66,8 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
78
66
  key: "getCenter",
79
67
  value: function getCenter() {
80
68
  var _this$transform$cente = this.transform.center,
81
- lng = _this$transform$cente.lng,
82
- lat = _this$transform$cente.lat;
69
+ lng = _this$transform$cente.lng,
70
+ lat = _this$transform$cente.lat;
83
71
  return new LngLat(lng, lat);
84
72
  }
85
73
  }, {
@@ -195,14 +183,16 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
195
183
  }, {
196
184
  key: "fitBounds",
197
185
  value: function fitBounds(bounds, options, eventData) {
198
- return this.fitInternal( // @ts-ignore
186
+ return this.fitInternal(
187
+ // @ts-ignore
199
188
  this.cameraForBounds(bounds, options), options, eventData);
200
189
  }
201
190
  }, {
202
191
  key: "cameraForBounds",
203
192
  value: function cameraForBounds(bounds, options) {
204
193
  bounds = LngLatBounds.convert(bounds);
205
- return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0, // @ts-ignore
194
+ return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0,
195
+ // @ts-ignore
206
196
  options);
207
197
  }
208
198
  }, {
@@ -211,7 +201,6 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
211
201
  if (Math.abs(this.getBearing()) < this.bearingSnap) {
212
202
  return this.resetNorth(options, eventData);
213
203
  }
214
-
215
204
  return this;
216
205
  }
217
206
  }, {
@@ -224,58 +213,47 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
224
213
  var zoomChanged = false;
225
214
  var bearingChanged = false;
226
215
  var pitchChanged = false;
227
-
228
216
  if (options.zoom !== undefined && tr.zoom !== +options.zoom) {
229
217
  zoomChanged = true;
230
218
  tr.zoom = +options.zoom;
231
219
  }
232
-
233
220
  if (options.center !== undefined) {
234
221
  tr.center = LngLat.convert(options.center);
235
222
  }
236
-
237
223
  if (options.bearing !== undefined && tr.bearing !== +options.bearing) {
238
224
  bearingChanged = true;
239
225
  tr.bearing = +options.bearing;
240
226
  }
241
-
242
227
  if (options.pitch !== undefined && tr.pitch !== +options.pitch) {
243
228
  pitchChanged = true;
244
229
  tr.pitch = +options.pitch;
245
230
  }
246
-
247
231
  if (options.padding !== undefined && !tr.isPaddingEqual(options.padding)) {
248
232
  tr.padding = options.padding;
249
233
  }
250
-
251
234
  this.emit('movestart', new Event('movestart', eventData));
252
235
  this.emit('move', new Event('move', eventData));
253
-
254
236
  if (zoomChanged) {
255
237
  this.emit('zoomstart', new Event('zoomstart', eventData));
256
238
  this.emit('zoom', new Event('zoom', eventData));
257
239
  this.emit('zoomend', new Event('zoomend', eventData));
258
240
  }
259
-
260
241
  if (bearingChanged) {
261
242
  this.emit('rotatestart', new Event('rotatestart', eventData));
262
243
  this.emit('rotate', new Event('rotate', eventData));
263
244
  this.emit('rotateend', new Event('rotateend', eventData));
264
245
  }
265
-
266
246
  if (pitchChanged) {
267
247
  this.emit('pitchstart', new Event('pitchstart', eventData));
268
248
  this.emit('pitch', new Event('pitch', eventData));
269
249
  this.emit('pitchend', new Event('pitchend', eventData));
270
250
  }
271
-
272
251
  return this.emit('moveend', new Event('moveend', eventData));
273
252
  }
274
253
  }, {
275
254
  key: "easeTo",
276
255
  value: function easeTo() {
277
256
  var _this2 = this;
278
-
279
257
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
280
258
  var eventData = arguments.length > 1 ? arguments[1] : undefined;
281
259
  options = merge({
@@ -283,11 +261,9 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
283
261
  duration: 500,
284
262
  easing: defaultEasing
285
263
  }, options);
286
-
287
264
  if (options.animate === false || !options.essential && prefersReducedMotion()) {
288
265
  options.duration = 0;
289
266
  }
290
-
291
267
  var tr = this.transform;
292
268
  var startZoom = this.getZoom();
293
269
  var startBearing = this.getBearing();
@@ -307,12 +283,10 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
307
283
  var finalScale = tr.zoomScale(zoom - startZoom);
308
284
  var around;
309
285
  var aroundPoint;
310
-
311
286
  if (options.around) {
312
287
  around = LngLat.convert(options.around);
313
288
  aroundPoint = tr.locationPoint(around);
314
289
  }
315
-
316
290
  var currently = {
317
291
  moving: this.moving,
318
292
  zooming: this.zooming,
@@ -330,22 +304,18 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
330
304
  if (_this2.zooming) {
331
305
  tr.zoom = interpolate(startZoom, zoom, k);
332
306
  }
333
-
334
307
  if (_this2.rotating && _this2.rotateEnabled) {
335
308
  tr.bearing = interpolate(startBearing, bearing, k);
336
309
  }
337
-
338
310
  if (_this2.pitching && _this2.pitchEnabled) {
339
311
  tr.pitch = interpolate(startPitch, pitch, k);
340
312
  }
341
-
342
313
  if (_this2.padding) {
343
- tr.interpolatePadding(startPadding, padding, k); // When padding is being applied, Transform#centerPoint is changing continously,
314
+ tr.interpolatePadding(startPadding, padding, k);
315
+ // When padding is being applied, Transform#centerPoint is changing continously,
344
316
  // thus we need to recalculate offsetPoint every fra,e
345
-
346
317
  pointAtOffset = tr.centerPoint.add(offsetAsPoint);
347
318
  }
348
-
349
319
  if (around) {
350
320
  tr.setLocationAtPoint(around, aroundPoint);
351
321
  } else {
@@ -355,11 +325,11 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
355
325
  var newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
356
326
  tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
357
327
  }
358
-
359
328
  _this2.fireMoveEvents(eventData);
360
329
  }, function (interruptingEaseId) {
361
330
  _this2.afterEase(eventData, interruptingEaseId);
362
- }, // @ts-ignore
331
+ },
332
+ // @ts-ignore
363
333
  options);
364
334
  return this;
365
335
  }
@@ -367,16 +337,13 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
367
337
  key: "flyTo",
368
338
  value: function flyTo() {
369
339
  var _this3 = this;
370
-
371
340
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
372
341
  var eventData = arguments.length > 1 ? arguments[1] : undefined;
373
-
374
342
  // Fall through to jumpTo if user has set prefers-reduced-motion
375
343
  if (!options.essential && prefersReducedMotion()) {
376
344
  var coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']);
377
345
  return this.jumpTo(coercedOptions, eventData);
378
346
  }
379
-
380
347
  this.stop();
381
348
  options = merge({
382
349
  offset: [0, 0],
@@ -401,95 +368,88 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
401
368
  this.normalizeCenter(center);
402
369
  var from = tr.project(locationAtOffset);
403
370
  var delta = tr.project(center).sub(from);
404
- var rho = options.curve; // w₀: Initial visible span, measured in pixels at the initial scale.
405
-
406
- var w0 = Math.max(tr.width, tr.height); // w₁: Final visible span, measured in pixels with respect to the initial scale.
371
+ var rho = options.curve;
407
372
 
408
- var w1 = w0 / scale; // Length of the flight path as projected onto the ground plane, measured in pixels from
373
+ // w₀: Initial visible span, measured in pixels at the initial scale.
374
+ var w0 = Math.max(tr.width, tr.height);
375
+ // w₁: Final visible span, measured in pixels with respect to the initial scale.
376
+ var w1 = w0 / scale;
377
+ // Length of the flight path as projected onto the ground plane, measured in pixels from
409
378
  // the world image origin at the initial scale.
410
-
411
379
  var u1 = delta.mag();
412
-
413
380
  if ('minZoom' in options) {
414
- var minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom); // w<sub>m</sub>: Maximum visible span, measured in pixels with respect to the initial
381
+ var minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);
382
+ // w<sub>m</sub>: Maximum visible span, measured in pixels with respect to the initial
415
383
  // scale.
416
-
417
384
  var wMax = w0 / tr.zoomScale(minZoom - startZoom);
418
385
  rho = Math.sqrt(wMax / u1 * 2);
419
- } // ρ²
420
-
386
+ }
421
387
 
388
+ // ρ²
422
389
  var rho2 = rho * rho;
390
+
423
391
  /**
424
392
  * rᵢ: Returns the zoom-out factor at one end of the animation.
425
393
  *
426
394
  * @param i 0 for the ascent or 1 for the descent.
427
395
  * @private
428
396
  */
429
-
430
397
  function r(i) {
431
398
  var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
432
399
  return Math.log(Math.sqrt(b * b + 1) - b);
433
400
  }
434
-
435
401
  function sinh(n) {
436
402
  return (Math.exp(n) - Math.exp(-n)) / 2;
437
403
  }
438
-
439
404
  function cosh(n) {
440
405
  return (Math.exp(n) + Math.exp(-n)) / 2;
441
406
  }
442
-
443
407
  function tanh(n) {
444
408
  return sinh(n) / cosh(n);
445
- } // r₀: Zoom-out factor during ascent.
409
+ }
446
410
 
411
+ // r₀: Zoom-out factor during ascent.
412
+ var r0 = r(0);
447
413
 
448
- var r0 = r(0); // w(s): Returns the visible span on the ground, measured in pixels with respect to the
414
+ // w(s): Returns the visible span on the ground, measured in pixels with respect to the
449
415
  // initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.
450
-
451
416
  var w = function w(s) {
452
417
  return cosh(r0) / cosh(r0 + rho * s);
453
- }; // u(s): Returns the distance along the flight path as projected onto the ground plane,
454
- // measured in pixels from the world image origin at the initial scale.
455
-
418
+ };
456
419
 
420
+ // u(s): Returns the distance along the flight path as projected onto the ground plane,
421
+ // measured in pixels from the world image origin at the initial scale.
457
422
  var u = function u(s) {
458
423
  return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
459
- }; // S: Total length of the flight path, measured in ρ-screenfuls.
460
-
424
+ };
461
425
 
462
- var S = (r(1) - r0) / rho; // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
426
+ // S: Total length of the flight path, measured in ρ-screenfuls.
427
+ var S = (r(1) - r0) / rho;
463
428
 
429
+ // When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
464
430
  if (Math.abs(u1) < 0.000001 || !isFinite(S)) {
465
431
  // Perform a more or less instantaneous transition if the path is too short.
466
432
  if (Math.abs(w0 - w1) < 0.000001) {
467
433
  return this.easeTo(options, eventData);
468
434
  }
469
-
470
435
  var k = w1 < w0 ? -1 : 1;
471
436
  S = Math.abs(Math.log(w1 / w0)) / rho;
472
-
473
437
  u = function u() {
474
438
  return 0;
475
439
  };
476
-
477
440
  w = function w(s) {
478
441
  return Math.exp(k * rho * s);
479
442
  };
480
443
  }
481
-
482
444
  if ('duration' in options) {
483
445
  options.duration = +options.duration;
484
446
  } else {
485
447
  var V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;
486
448
  options.duration = 1000 * S / V;
487
449
  }
488
-
489
450
  if (options.maxDuration && options.duration > options.maxDuration) {
490
451
  options.duration = 0;
491
452
  }
492
-
493
453
  this.zooming = true;
494
454
  this.rotating = startBearing !== bearing;
495
455
  this.pitching = pitch !== startPitch;
@@ -497,29 +457,24 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
497
457
  this.prepareEase(eventData, false);
498
458
  this.ease(function (k) {
499
459
  // s: The distance traveled along the flight path, measured in ρ-screenfuls.
500
- var s = k * S; // @ts-ignore
501
-
460
+ var s = k * S;
461
+ // @ts-ignore
502
462
  var easeScale = 1 / w(s);
503
463
  tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(easeScale);
504
-
505
464
  if (_this3.rotating) {
506
465
  tr.bearing = interpolate(startBearing, bearing, k);
507
466
  }
508
-
509
467
  if (_this3.pitching) {
510
468
  tr.pitch = interpolate(startPitch, pitch, k);
511
469
  }
512
-
513
470
  if (_this3.padding) {
514
- tr.interpolatePadding(startPadding, padding, k); // When padding is being applied, Transform#centerPoint is changing continously,
471
+ tr.interpolatePadding(startPadding, padding, k);
472
+ // When padding is being applied, Transform#centerPoint is changing continously,
515
473
  // thus we need to recalculate offsetPoint every frame
516
-
517
474
  pointAtOffset = tr.centerPoint.add(offsetAsPoint);
518
475
  }
519
-
520
476
  var newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(easeScale));
521
477
  tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
522
-
523
478
  _this3.fireMoveEvents(eventData);
524
479
  }, function () {
525
480
  return _this3.afterEase(eventData);
@@ -529,35 +484,35 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
529
484
  }, {
530
485
  key: "fitScreenCoordinates",
531
486
  value: function fitScreenCoordinates(p0, p1, bearing, options, eventData) {
532
- return this.fitInternal( // @ts-ignore
533
- this.cameraForBoxAndBearing(this.transform.pointLocation(Point.convert(p0)), this.transform.pointLocation(Point.convert(p1)), bearing, // @ts-ignore
487
+ return this.fitInternal(
488
+ // @ts-ignore
489
+ this.cameraForBoxAndBearing(this.transform.pointLocation(Point.convert(p0)), this.transform.pointLocation(Point.convert(p1)), bearing,
490
+ // @ts-ignore
534
491
  options), options, eventData);
535
492
  }
536
493
  }, {
537
494
  key: "stop",
538
495
  value: function stop(allowGestures, easeId) {
539
496
  if (this.easeFrameId) {
540
- this.cancelRenderFrame(this.easeFrameId); // @ts-ignore
541
-
542
- delete this.easeFrameId; // @ts-ignore
543
-
497
+ this.cancelRenderFrame(this.easeFrameId);
498
+ // @ts-ignore
499
+ delete this.easeFrameId;
500
+ // @ts-ignore
544
501
  delete this.onEaseFrame;
545
502
  }
546
-
547
503
  if (this.onEaseEnd) {
548
504
  // The _onEaseEnd function might emit events which trigger new
549
505
  // animation, which sets a new _onEaseEnd. Ensure we don't delete
550
506
  // it unintentionally.
551
- var onEaseEnd = this.onEaseEnd; // @ts-ignore
552
-
507
+ var onEaseEnd = this.onEaseEnd;
508
+ // @ts-ignore
553
509
  delete this.onEaseEnd;
554
510
  onEaseEnd.call(this, easeId);
555
- } // if (!allowGestures) {
511
+ }
512
+ // if (!allowGestures) {
556
513
  // const handlers = (this: any).handlers;
557
514
  // if (handlers) handlers.stop();
558
515
  // }
559
-
560
-
561
516
  return this;
562
517
  }
563
518
  }, {
@@ -565,26 +520,21 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
565
520
  value: function normalizeBearing(bearing, currentBearing) {
566
521
  bearing = wrap(bearing, -180, 180);
567
522
  var diff = Math.abs(bearing - currentBearing);
568
-
569
523
  if (Math.abs(bearing - 360 - currentBearing) < diff) {
570
524
  bearing -= 360;
571
525
  }
572
-
573
526
  if (Math.abs(bearing + 360 - currentBearing) < diff) {
574
527
  bearing += 360;
575
528
  }
576
-
577
529
  return bearing;
578
530
  }
579
531
  }, {
580
532
  key: "normalizeCenter",
581
533
  value: function normalizeCenter(center) {
582
534
  var tr = this.transform;
583
-
584
535
  if (!tr.renderWorldCopies || tr.lngRange) {
585
536
  return;
586
537
  }
587
-
588
538
  var delta = center.lng - tr.center.lng;
589
539
  center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
590
540
  }
@@ -592,15 +542,12 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
592
542
  key: "fireMoveEvents",
593
543
  value: function fireMoveEvents(eventData) {
594
544
  this.emit('move', new Event('move', eventData));
595
-
596
545
  if (this.zooming) {
597
546
  this.emit('zoom', new Event('zoom', eventData));
598
547
  }
599
-
600
548
  if (this.rotating) {
601
549
  this.emit('rotate', new Event('rotate', eventData));
602
550
  }
603
-
604
551
  if (this.pitching) {
605
552
  this.emit('rotate', new Event('pitch', eventData));
606
553
  }
@@ -611,19 +558,15 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
611
558
  var noMoveStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
612
559
  var currently = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
613
560
  this.moving = true;
614
-
615
561
  if (!noMoveStart && !currently.moving) {
616
562
  this.emit('movestart', new Event('movestart', eventData));
617
563
  }
618
-
619
564
  if (this.zooming && !currently.zooming) {
620
565
  this.emit('zoomstart', new Event('zoomstart', eventData));
621
566
  }
622
-
623
567
  if (this.rotating && !currently.rotating) {
624
568
  this.emit('rotatestart', new Event('rotatestart', eventData));
625
569
  }
626
-
627
570
  if (this.pitching && !currently.pitching) {
628
571
  this.emit('pitchstart', new Event('pitchstart', eventData));
629
572
  }
@@ -635,9 +578,8 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
635
578
  // the same id then don't fire any events to avoid extra start/stop events
636
579
  if (this.easeId && easeId && this.easeId === easeId) {
637
580
  return;
638
- } // @ts-ignore
639
-
640
-
581
+ }
582
+ // @ts-ignore
641
583
  delete this.easeId;
642
584
  var wasZooming = this.zooming;
643
585
  var wasRotating = this.rotating;
@@ -647,19 +589,15 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
647
589
  this.rotating = false;
648
590
  this.pitching = false;
649
591
  this.padding = false;
650
-
651
592
  if (wasZooming) {
652
593
  this.emit('zoomend', new Event('zoomend', eventData));
653
594
  }
654
-
655
595
  if (wasRotating) {
656
596
  this.emit('rotateend', new Event('rotateend', eventData));
657
597
  }
658
-
659
598
  if (wasPitching) {
660
599
  this.emit('pitchend', new Event('pitchend', eventData));
661
600
  }
662
-
663
601
  this.emit('moveend', new Event('moveend', eventData));
664
602
  }
665
603
  }, {
@@ -690,7 +628,6 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
690
628
  offset: [0, 0],
691
629
  maxZoom: this.transform.maxZoom
692
630
  }, options);
693
-
694
631
  if (typeof options.padding === 'number') {
695
632
  var p = options.padding;
696
633
  options.padding = {
@@ -700,41 +637,49 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
700
637
  left: p
701
638
  };
702
639
  }
703
-
704
640
  options.padding = merge(defaultPadding, options.padding);
705
641
  var tr = this.transform;
706
- var edgePadding = tr.padding; // We want to calculate the upper right and lower left of the box defined by p0 and p1
707
- // in a coordinate system rotate to match the destination bearing.
642
+ var edgePadding = tr.padding;
708
643
 
644
+ // We want to calculate the upper right and lower left of the box defined by p0 and p1
645
+ // in a coordinate system rotate to match the destination bearing.
709
646
  var p0world = tr.project(LngLat.convert(p0));
710
647
  var p1world = tr.project(LngLat.convert(p1));
711
648
  var p0rotated = p0world.rotate(-bearing * Math.PI / 180);
712
649
  var p1rotated = p1world.rotate(-bearing * Math.PI / 180);
713
650
  var upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));
714
- var lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y)); // Calculate zoom: consider the original bbox and padding.
651
+ var lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));
715
652
 
653
+ // Calculate zoom: consider the original bbox and padding.
716
654
  var size = upperRight.sub(lowerLeft);
717
- var scaleX = (tr.width - ( // @ts-ignore
718
- edgePadding.left + // @ts-ignore
719
- edgePadding.right + // @ts-ignore
720
- options.padding.left + // @ts-ignore
655
+ var scaleX = (tr.width - (
656
+ // @ts-ignore
657
+ edgePadding.left +
658
+ // @ts-ignore
659
+ edgePadding.right +
660
+ // @ts-ignore
661
+ options.padding.left +
662
+ // @ts-ignore
721
663
  options.padding.right)) / size.x;
722
- var scaleY = (tr.height - ( // @ts-ignore
723
- edgePadding.top + // @ts-ignore
724
- edgePadding.bottom + // @ts-ignore
725
- options.padding.top + // @ts-ignore
664
+ var scaleY = (tr.height - (
665
+ // @ts-ignore
666
+ edgePadding.top +
667
+ // @ts-ignore
668
+ edgePadding.bottom +
669
+ // @ts-ignore
670
+ options.padding.top +
671
+ // @ts-ignore
726
672
  options.padding.bottom)) / size.y;
727
-
728
673
  if (scaleY < 0 || scaleX < 0) {
729
674
  return;
730
675
  }
676
+ var zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
731
677
 
732
- var zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom); // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.
733
-
734
- var offset = Point.convert(options.offset); // @ts-ignore
735
-
736
- var paddingOffsetX = (options.padding.left - options.padding.right) / 2; // @ts-ignore
737
-
678
+ // Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.
679
+ var offset = Point.convert(options.offset);
680
+ // @ts-ignore
681
+ var paddingOffsetX = (options.padding.left - options.padding.right) / 2;
682
+ // @ts-ignore
738
683
  var paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;
739
684
  var offsetAtInitialZoom = new Point(offset.x + paddingOffsetX, offset.y + paddingOffsetY);
740
685
  var offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));
@@ -752,16 +697,13 @@ var Camera = /*#__PURE__*/function (_EventEmitter) {
752
697
  if (!calculatedOptions) {
753
698
  return this;
754
699
  }
755
-
756
- options = merge(calculatedOptions, options); // Explictly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.
757
-
758
- delete options.padding; // @ts-ignore
759
-
700
+ options = merge(calculatedOptions, options);
701
+ // Explictly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.
702
+ delete options.padding;
703
+ // @ts-ignore
760
704
  return options.linear ? this.easeTo(options, eventData) : this.flyTo(options, eventData);
761
705
  }
762
706
  }]);
763
-
764
707
  return Camera;
765
708
  }(EventEmitter);
766
-
767
709
  export { Camera as default };