@antv/l7-map 2.21.0 → 2.21.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 (158) hide show
  1. package/es/camera.js +595 -674
  2. package/es/earthmap.js +313 -276
  3. package/es/geo/edge_insets.js +57 -72
  4. package/es/geo/lng_lat.js +50 -64
  5. package/es/geo/lng_lat_bounds.js +101 -137
  6. package/es/geo/mercator.js +23 -35
  7. package/es/geo/point.js +150 -221
  8. package/es/geo/simple.js +22 -34
  9. package/es/geo/transform.js +839 -905
  10. package/es/handler/blockable_map_event.js +46 -66
  11. package/es/handler/box_zoom.js +125 -143
  12. package/es/handler/click_zoom.js +37 -51
  13. package/es/handler/events/event.js +11 -9
  14. package/es/handler/events/map_mouse_event.js +39 -54
  15. package/es/handler/events/map_touch_event.js +54 -73
  16. package/es/handler/events/map_wheel_event.js +22 -38
  17. package/es/handler/events/render_event.js +6 -23
  18. package/es/handler/handler_inertia.js +98 -113
  19. package/es/handler/handler_manager.js +349 -437
  20. package/es/handler/handler_util.js +2 -2
  21. package/es/handler/keyboard.js +98 -110
  22. package/es/handler/map_event.js +81 -117
  23. package/es/handler/mouse/mouse_handler.js +81 -100
  24. package/es/handler/mouse/mousepan_handler.js +16 -39
  25. package/es/handler/mouse/mousepitch_hander.js +18 -40
  26. package/es/handler/mouse/mouserotate_hander.js +18 -40
  27. package/es/handler/mouse/util.js +7 -6
  28. package/es/handler/scroll_zoom.js +221 -231
  29. package/es/handler/shim/dblclick_zoom.js +36 -47
  30. package/es/handler/shim/drag_pan.js +41 -50
  31. package/es/handler/shim/drag_rotate.js +38 -48
  32. package/es/handler/shim/touch_zoom_rotate.js +68 -79
  33. package/es/handler/tap/single_tap_recognizer.js +60 -80
  34. package/es/handler/tap/tap_drag_zoom.js +72 -89
  35. package/es/handler/tap/tap_recognizer.js +37 -45
  36. package/es/handler/tap/tap_zoom.js +67 -95
  37. package/es/handler/touch/touch_pan.js +77 -96
  38. package/es/handler/touch/touch_pitch.js +61 -79
  39. package/es/handler/touch/touch_rotate.js +47 -67
  40. package/es/handler/touch/touch_zoom.js +29 -46
  41. package/es/handler/touch/two_touch.js +79 -104
  42. package/es/hash.js +75 -88
  43. package/es/map.js +318 -284
  44. package/es/util.js +18 -37
  45. package/es/utils/Aabb.js +60 -100
  46. package/es/utils/dom.js +32 -55
  47. package/es/utils/performance.js +25 -29
  48. package/es/utils/primitives.js +33 -43
  49. package/es/utils/task_queue.js +47 -76
  50. package/lib/camera.d.ts +86 -0
  51. package/lib/camera.js +597 -672
  52. package/lib/earthmap.d.ts +69 -0
  53. package/lib/earthmap.js +314 -276
  54. package/lib/geo/edge_insets.d.ts +54 -0
  55. package/lib/geo/edge_insets.js +58 -70
  56. package/lib/geo/lng_lat.d.ts +18 -0
  57. package/lib/geo/lng_lat.js +50 -62
  58. package/lib/geo/lng_lat_bounds.d.ts +25 -0
  59. package/lib/geo/lng_lat_bounds.js +102 -136
  60. package/lib/geo/mercator.d.ts +30 -0
  61. package/lib/geo/mercator.js +26 -37
  62. package/lib/geo/point.d.ts +40 -0
  63. package/lib/geo/point.js +151 -220
  64. package/lib/geo/simple.d.ts +30 -0
  65. package/lib/geo/simple.js +25 -36
  66. package/lib/geo/transform.d.ts +198 -0
  67. package/lib/geo/transform.js +844 -907
  68. package/lib/handler/IHandler.d.ts +34 -0
  69. package/lib/handler/blockable_map_event.d.ts +17 -0
  70. package/lib/handler/blockable_map_event.js +48 -65
  71. package/lib/handler/box_zoom.d.ts +59 -0
  72. package/lib/handler/box_zoom.js +126 -143
  73. package/lib/handler/click_zoom.d.ts +16 -0
  74. package/lib/handler/click_zoom.js +38 -50
  75. package/lib/handler/events/event.d.ts +4 -0
  76. package/lib/handler/events/event.js +12 -9
  77. package/lib/handler/events/index.d.ts +4 -0
  78. package/lib/handler/events/index.js +3 -3
  79. package/lib/handler/events/map_mouse_event.d.ts +34 -0
  80. package/lib/handler/events/map_mouse_event.js +41 -52
  81. package/lib/handler/events/map_touch_event.d.ts +57 -0
  82. package/lib/handler/events/map_touch_event.js +56 -71
  83. package/lib/handler/events/map_wheel_event.d.ts +33 -0
  84. package/lib/handler/events/map_wheel_event.js +23 -37
  85. package/lib/handler/events/render_event.d.ts +5 -0
  86. package/lib/handler/events/render_event.js +7 -22
  87. package/lib/handler/handler_inertia.d.ts +23 -0
  88. package/lib/handler/handler_inertia.js +102 -112
  89. package/lib/handler/handler_manager.d.ts +61 -0
  90. package/lib/handler/handler_manager.js +351 -437
  91. package/lib/handler/handler_util.d.ts +4 -0
  92. package/lib/handler/handler_util.js +2 -2
  93. package/lib/handler/keyboard.d.ts +36 -0
  94. package/lib/handler/keyboard.js +98 -110
  95. package/lib/handler/map_event.d.ts +29 -0
  96. package/lib/handler/map_event.js +83 -116
  97. package/lib/handler/mouse/index.d.ts +4 -0
  98. package/lib/handler/mouse/index.js +3 -3
  99. package/lib/handler/mouse/mouse_handler.d.ts +22 -0
  100. package/lib/handler/mouse/mouse_handler.js +83 -99
  101. package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
  102. package/lib/handler/mouse/mousepan_handler.js +19 -38
  103. package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
  104. package/lib/handler/mouse/mousepitch_hander.js +21 -39
  105. package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
  106. package/lib/handler/mouse/mouserotate_hander.js +21 -39
  107. package/lib/handler/mouse/util.d.ts +6 -0
  108. package/lib/handler/mouse/util.js +7 -7
  109. package/lib/handler/scroll_zoom.d.ts +93 -0
  110. package/lib/handler/scroll_zoom.js +221 -231
  111. package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
  112. package/lib/handler/shim/dblclick_zoom.js +37 -46
  113. package/lib/handler/shim/drag_pan.d.ts +61 -0
  114. package/lib/handler/shim/drag_pan.js +42 -49
  115. package/lib/handler/shim/drag_rotate.d.ts +46 -0
  116. package/lib/handler/shim/drag_rotate.js +39 -47
  117. package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
  118. package/lib/handler/shim/touch_zoom_rotate.js +69 -78
  119. package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
  120. package/lib/handler/tap/single_tap_recognizer.js +63 -79
  121. package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
  122. package/lib/handler/tap/tap_drag_zoom.js +74 -88
  123. package/lib/handler/tap/tap_recognizer.d.ts +17 -0
  124. package/lib/handler/tap/tap_recognizer.js +41 -47
  125. package/lib/handler/tap/tap_zoom.d.ts +22 -0
  126. package/lib/handler/tap/tap_zoom.js +69 -94
  127. package/lib/handler/touch/index.d.ts +5 -0
  128. package/lib/handler/touch/index.js +4 -4
  129. package/lib/handler/touch/touch_pan.d.ts +30 -0
  130. package/lib/handler/touch/touch_pan.js +79 -95
  131. package/lib/handler/touch/touch_pitch.d.ts +13 -0
  132. package/lib/handler/touch/touch_pitch.js +64 -78
  133. package/lib/handler/touch/touch_rotate.d.ts +12 -0
  134. package/lib/handler/touch/touch_rotate.js +50 -66
  135. package/lib/handler/touch/touch_zoom.d.ts +12 -0
  136. package/lib/handler/touch/touch_zoom.js +32 -45
  137. package/lib/handler/touch/two_touch.d.ts +23 -0
  138. package/lib/handler/touch/two_touch.js +81 -103
  139. package/lib/hash.d.ts +14 -0
  140. package/lib/hash.js +75 -88
  141. package/lib/index.d.ts +4 -0
  142. package/lib/index.js +4 -4
  143. package/lib/interface.d.ts +34 -0
  144. package/lib/map.d.ts +70 -0
  145. package/lib/map.js +319 -284
  146. package/lib/util.d.ts +25 -0
  147. package/lib/util.js +20 -36
  148. package/lib/utils/Aabb.d.ts +12 -0
  149. package/lib/utils/Aabb.js +61 -99
  150. package/lib/utils/dom.d.ts +4 -0
  151. package/lib/utils/dom.js +34 -55
  152. package/lib/utils/performance.d.ts +17 -0
  153. package/lib/utils/performance.js +25 -29
  154. package/lib/utils/primitives.d.ts +6 -0
  155. package/lib/utils/primitives.js +34 -42
  156. package/lib/utils/task_queue.d.ts +13 -0
  157. package/lib/utils/task_queue.js +47 -76
  158. package/package.json +25 -32
@@ -1,106 +1,89 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
 
5
4
  import { MAX_TAP_INTERVAL } from "./single_tap_recognizer";
6
5
  import TapRecognizer from "./tap_recognizer";
7
- var TapDragZoomHandler = /*#__PURE__*/function () {
8
- function TapDragZoomHandler() {
9
- _classCallCheck(this, TapDragZoomHandler);
6
+ export default class TapDragZoomHandler {
7
+ constructor() {
8
+ _defineProperty(this, "enabled", void 0);
9
+ _defineProperty(this, "active", void 0);
10
+ _defineProperty(this, "swipePoint", void 0);
11
+ _defineProperty(this, "swipeTouch", void 0);
12
+ _defineProperty(this, "tapTime", void 0);
13
+ _defineProperty(this, "tap", void 0);
10
14
  this.tap = new TapRecognizer({
11
15
  numTouches: 1,
12
16
  numTaps: 1
13
17
  });
14
18
  this.reset();
15
19
  }
16
- _createClass(TapDragZoomHandler, [{
17
- key: "reset",
18
- value: function reset() {
19
- this.active = false;
20
- // @ts-ignore
21
- delete this.swipePoint;
22
- // @ts-ignore
23
- delete this.swipeTouch;
24
- // @ts-ignore
25
- delete this.tapTime;
26
- this.tap.reset();
20
+ reset() {
21
+ this.active = false;
22
+ // @ts-ignore
23
+ delete this.swipePoint;
24
+ // @ts-ignore
25
+ delete this.swipeTouch;
26
+ // @ts-ignore
27
+ delete this.tapTime;
28
+ this.tap.reset();
29
+ }
30
+ touchstart(e, points, mapTouches) {
31
+ if (this.swipePoint) {
32
+ return;
33
+ }
34
+ if (this.tapTime && e.timeStamp - this.tapTime > MAX_TAP_INTERVAL) {
35
+ this.reset();
36
+ }
37
+ if (!this.tapTime) {
38
+ this.tap.touchstart(e, points, mapTouches);
39
+ } else if (mapTouches.length > 0) {
40
+ this.swipePoint = points[0];
41
+ this.swipeTouch = mapTouches[0].identifier;
27
42
  }
28
- }, {
29
- key: "touchstart",
30
- value: function touchstart(e, points, mapTouches) {
31
- if (this.swipePoint) {
43
+ }
44
+ touchmove(e, points, mapTouches) {
45
+ if (!this.tapTime) {
46
+ this.tap.touchmove(e, points, mapTouches);
47
+ } else if (this.swipePoint) {
48
+ if (mapTouches[0].identifier !== this.swipeTouch) {
32
49
  return;
33
50
  }
34
- if (this.tapTime && e.timeStamp - this.tapTime > MAX_TAP_INTERVAL) {
35
- this.reset();
36
- }
37
- if (!this.tapTime) {
38
- this.tap.touchstart(e, points, mapTouches);
39
- } else if (mapTouches.length > 0) {
40
- this.swipePoint = points[0];
41
- this.swipeTouch = mapTouches[0].identifier;
42
- }
51
+ const newSwipePoint = points[0];
52
+ const dist = newSwipePoint.y - this.swipePoint.y;
53
+ this.swipePoint = newSwipePoint;
54
+ e.preventDefault();
55
+ this.active = true;
56
+ return {
57
+ zoomDelta: dist / 128
58
+ };
43
59
  }
44
- }, {
45
- key: "touchmove",
46
- value: function touchmove(e, points, mapTouches) {
47
- if (!this.tapTime) {
48
- this.tap.touchmove(e, points, mapTouches);
49
- } else if (this.swipePoint) {
50
- if (mapTouches[0].identifier !== this.swipeTouch) {
51
- return;
52
- }
53
- var newSwipePoint = points[0];
54
- var dist = newSwipePoint.y - this.swipePoint.y;
55
- this.swipePoint = newSwipePoint;
56
- e.preventDefault();
57
- this.active = true;
58
- return {
59
- zoomDelta: dist / 128
60
- };
60
+ }
61
+ touchend(e, points, mapTouches) {
62
+ if (!this.tapTime) {
63
+ const point = this.tap.touchend(e, points, mapTouches);
64
+ if (point) {
65
+ this.tapTime = e.timeStamp;
61
66
  }
62
- }
63
- }, {
64
- key: "touchend",
65
- value: function touchend(e, points, mapTouches) {
66
- if (!this.tapTime) {
67
- var point = this.tap.touchend(e, points, mapTouches);
68
- if (point) {
69
- this.tapTime = e.timeStamp;
70
- }
71
- } else if (this.swipePoint) {
72
- if (mapTouches.length === 0) {
73
- this.reset();
74
- }
67
+ } else if (this.swipePoint) {
68
+ if (mapTouches.length === 0) {
69
+ this.reset();
75
70
  }
76
71
  }
77
- }, {
78
- key: "touchcancel",
79
- value: function touchcancel() {
80
- this.reset();
81
- }
82
- }, {
83
- key: "enable",
84
- value: function enable() {
85
- this.enabled = true;
86
- }
87
- }, {
88
- key: "disable",
89
- value: function disable() {
90
- this.enabled = false;
91
- this.reset();
92
- }
93
- }, {
94
- key: "isEnabled",
95
- value: function isEnabled() {
96
- return this.enabled;
97
- }
98
- }, {
99
- key: "isActive",
100
- value: function isActive() {
101
- return this.active;
102
- }
103
- }]);
104
- return TapDragZoomHandler;
105
- }();
106
- export { TapDragZoomHandler as default };
72
+ }
73
+ touchcancel() {
74
+ this.reset();
75
+ }
76
+ enable() {
77
+ this.enabled = true;
78
+ }
79
+ disable() {
80
+ this.enabled = false;
81
+ this.reset();
82
+ }
83
+ isEnabled() {
84
+ return this.enabled;
85
+ }
86
+ isActive() {
87
+ return this.active;
88
+ }
89
+ }
@@ -1,54 +1,46 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
 
5
4
  import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
6
- var TapRecognizer = /*#__PURE__*/function () {
7
- function TapRecognizer(options) {
8
- _classCallCheck(this, TapRecognizer);
5
+ export default class TapRecognizer {
6
+ constructor(options) {
7
+ _defineProperty(this, "singleTap", void 0);
8
+ _defineProperty(this, "numTaps", void 0);
9
+ _defineProperty(this, "lastTime", void 0);
10
+ _defineProperty(this, "lastTap", void 0);
11
+ _defineProperty(this, "count", void 0);
9
12
  this.singleTap = new SingleTapRecognizer(options);
10
13
  this.numTaps = options.numTaps;
11
14
  this.reset();
12
15
  }
13
- _createClass(TapRecognizer, [{
14
- key: "reset",
15
- value: function reset() {
16
- this.lastTime = Infinity;
17
- // @ts-ignore
18
- delete this.lastTap;
19
- this.count = 0;
20
- this.singleTap.reset();
21
- }
22
- }, {
23
- key: "touchstart",
24
- value: function touchstart(e, points, mapTouches) {
25
- this.singleTap.touchstart(e, points, mapTouches);
26
- }
27
- }, {
28
- key: "touchmove",
29
- value: function touchmove(e, points, mapTouches) {
30
- this.singleTap.touchmove(e, points, mapTouches);
31
- }
32
- }, {
33
- key: "touchend",
34
- value: function touchend(e, points, mapTouches) {
35
- var tap = this.singleTap.touchend(e, points, mapTouches);
36
- if (tap) {
37
- var soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
38
- var closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
39
- if (!soonEnough || !closeEnough) {
40
- this.reset();
41
- }
42
- this.count++;
43
- this.lastTime = e.timeStamp;
44
- this.lastTap = tap;
45
- if (this.count === this.numTaps) {
46
- this.reset();
47
- return tap;
48
- }
16
+ reset() {
17
+ this.lastTime = Infinity;
18
+ // @ts-ignore
19
+ delete this.lastTap;
20
+ this.count = 0;
21
+ this.singleTap.reset();
22
+ }
23
+ touchstart(e, points, mapTouches) {
24
+ this.singleTap.touchstart(e, points, mapTouches);
25
+ }
26
+ touchmove(e, points, mapTouches) {
27
+ this.singleTap.touchmove(e, points, mapTouches);
28
+ }
29
+ touchend(e, points, mapTouches) {
30
+ const tap = this.singleTap.touchend(e, points, mapTouches);
31
+ if (tap) {
32
+ const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
33
+ const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
34
+ if (!soonEnough || !closeEnough) {
35
+ this.reset();
36
+ }
37
+ this.count++;
38
+ this.lastTime = e.timeStamp;
39
+ this.lastTap = tap;
40
+ if (this.count === this.numTaps) {
41
+ this.reset();
42
+ return tap;
49
43
  }
50
44
  }
51
- }]);
52
- return TapRecognizer;
53
- }();
54
- export { TapRecognizer as default };
45
+ }
46
+ }
@@ -1,11 +1,13 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
 
5
4
  import TapRecognizer from "./tap_recognizer";
6
- var TapZoomHandler = /*#__PURE__*/function () {
7
- function TapZoomHandler() {
8
- _classCallCheck(this, TapZoomHandler);
5
+ export default class TapZoomHandler {
6
+ constructor() {
7
+ _defineProperty(this, "enabled", void 0);
8
+ _defineProperty(this, "active", void 0);
9
+ _defineProperty(this, "zoomIn", void 0);
10
+ _defineProperty(this, "zoomOut", void 0);
9
11
  this.zoomIn = new TapRecognizer({
10
12
  numTouches: 1,
11
13
  numTaps: 2
@@ -16,94 +18,64 @@ var TapZoomHandler = /*#__PURE__*/function () {
16
18
  });
17
19
  this.reset();
18
20
  }
19
- _createClass(TapZoomHandler, [{
20
- key: "reset",
21
- value: function reset() {
22
- this.active = false;
23
- this.zoomIn.reset();
24
- this.zoomOut.reset();
25
- }
26
- }, {
27
- key: "touchstart",
28
- value: function touchstart(e, points, mapTouches) {
29
- this.zoomIn.touchstart(e, points, mapTouches);
30
- this.zoomOut.touchstart(e, points, mapTouches);
31
- }
32
- }, {
33
- key: "touchmove",
34
- value: function touchmove(e, points, mapTouches) {
35
- this.zoomIn.touchmove(e, points, mapTouches);
36
- this.zoomOut.touchmove(e, points, mapTouches);
37
- }
38
- }, {
39
- key: "touchend",
40
- value: function touchend(e, points, mapTouches) {
41
- var _this = this;
42
- var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
43
- var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
44
- if (zoomInPoint) {
45
- this.active = true;
46
- e.preventDefault();
47
- setTimeout(function () {
48
- return _this.reset();
49
- }, 0);
50
- return {
51
- cameraAnimation: function cameraAnimation(map) {
52
- return map.easeTo({
53
- duration: 300,
54
- zoom: map.getZoom() + 1,
55
- around: map.unproject(zoomInPoint)
56
- }, {
57
- originalEvent: e
58
- });
59
- }
60
- };
61
- } else if (zoomOutPoint) {
62
- this.active = true;
63
- e.preventDefault();
64
- setTimeout(function () {
65
- return _this.reset();
66
- }, 0);
67
- return {
68
- cameraAnimation: function cameraAnimation(map) {
69
- return map.easeTo({
70
- duration: 300,
71
- zoom: map.getZoom() - 1,
72
- around: map.unproject(zoomOutPoint)
73
- }, {
74
- originalEvent: e
75
- });
76
- }
77
- };
78
- }
79
- }
80
- }, {
81
- key: "touchcancel",
82
- value: function touchcancel() {
83
- this.reset();
84
- }
85
- }, {
86
- key: "enable",
87
- value: function enable() {
88
- this.enabled = true;
89
- }
90
- }, {
91
- key: "disable",
92
- value: function disable() {
93
- this.enabled = false;
94
- this.reset();
95
- }
96
- }, {
97
- key: "isEnabled",
98
- value: function isEnabled() {
99
- return this.enabled;
100
- }
101
- }, {
102
- key: "isActive",
103
- value: function isActive() {
104
- return this.active;
21
+ reset() {
22
+ this.active = false;
23
+ this.zoomIn.reset();
24
+ this.zoomOut.reset();
25
+ }
26
+ touchstart(e, points, mapTouches) {
27
+ this.zoomIn.touchstart(e, points, mapTouches);
28
+ this.zoomOut.touchstart(e, points, mapTouches);
29
+ }
30
+ touchmove(e, points, mapTouches) {
31
+ this.zoomIn.touchmove(e, points, mapTouches);
32
+ this.zoomOut.touchmove(e, points, mapTouches);
33
+ }
34
+ touchend(e, points, mapTouches) {
35
+ const zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
36
+ const zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
37
+ if (zoomInPoint) {
38
+ this.active = true;
39
+ e.preventDefault();
40
+ setTimeout(() => this.reset(), 0);
41
+ return {
42
+ cameraAnimation: map => map.easeTo({
43
+ duration: 300,
44
+ zoom: map.getZoom() + 1,
45
+ around: map.unproject(zoomInPoint)
46
+ }, {
47
+ originalEvent: e
48
+ })
49
+ };
50
+ } else if (zoomOutPoint) {
51
+ this.active = true;
52
+ e.preventDefault();
53
+ setTimeout(() => this.reset(), 0);
54
+ return {
55
+ cameraAnimation: map => map.easeTo({
56
+ duration: 300,
57
+ zoom: map.getZoom() - 1,
58
+ around: map.unproject(zoomOutPoint)
59
+ }, {
60
+ originalEvent: e
61
+ })
62
+ };
105
63
  }
106
- }]);
107
- return TapZoomHandler;
108
- }();
109
- export { TapZoomHandler as default };
64
+ }
65
+ touchcancel() {
66
+ this.reset();
67
+ }
68
+ enable() {
69
+ this.enabled = true;
70
+ }
71
+ disable() {
72
+ this.enabled = false;
73
+ this.reset();
74
+ }
75
+ isEnabled() {
76
+ return this.enabled;
77
+ }
78
+ isActive() {
79
+ return this.active;
80
+ }
81
+ }
@@ -1,110 +1,91 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
  import Point from "../../geo/point";
5
4
  import { indexTouches } from "../handler_util";
6
- var TouchPanHandler = /*#__PURE__*/function () {
7
- function TouchPanHandler(options) {
8
- _classCallCheck(this, TouchPanHandler);
5
+ export default class TouchPanHandler {
6
+ constructor(options) {
7
+ _defineProperty(this, "enabled", void 0);
8
+ _defineProperty(this, "active", void 0);
9
+ _defineProperty(this, "touches", void 0);
10
+ _defineProperty(this, "minTouches", void 0);
11
+ _defineProperty(this, "clickTolerance", void 0);
12
+ _defineProperty(this, "sum", void 0);
9
13
  this.minTouches = 1;
10
14
  this.clickTolerance = options.clickTolerance || 1;
11
15
  this.reset();
12
16
  }
13
- _createClass(TouchPanHandler, [{
14
- key: "reset",
15
- value: function reset() {
16
- this.active = false;
17
- this.touches = {};
18
- this.sum = new Point(0, 0);
19
- }
20
- }, {
21
- key: "touchstart",
22
- value: function touchstart(e, points, mapTouches) {
23
- return this.calculateTransform(e, points, mapTouches);
24
- }
25
- }, {
26
- key: "touchmove",
27
- value: function touchmove(e, points, mapTouches) {
28
- if (!this.active) {
29
- return;
30
- }
31
- e.preventDefault();
32
- return this.calculateTransform(e, points, mapTouches);
33
- }
34
- }, {
35
- key: "touchend",
36
- value: function touchend(e, points, mapTouches) {
37
- this.calculateTransform(e, points, mapTouches);
38
- if (this.active && mapTouches.length < this.minTouches) {
39
- this.reset();
40
- }
41
- }
42
- }, {
43
- key: "touchcancel",
44
- value: function touchcancel() {
45
- this.reset();
46
- }
47
- }, {
48
- key: "enable",
49
- value: function enable() {
50
- this.enabled = true;
17
+ reset() {
18
+ this.active = false;
19
+ this.touches = {};
20
+ this.sum = new Point(0, 0);
21
+ }
22
+ touchstart(e, points, mapTouches) {
23
+ return this.calculateTransform(e, points, mapTouches);
24
+ }
25
+ touchmove(e, points, mapTouches) {
26
+ if (!this.active) {
27
+ return;
51
28
  }
52
- }, {
53
- key: "disable",
54
- value: function disable() {
55
- this.enabled = false;
29
+ e.preventDefault();
30
+ return this.calculateTransform(e, points, mapTouches);
31
+ }
32
+ touchend(e, points, mapTouches) {
33
+ this.calculateTransform(e, points, mapTouches);
34
+ if (this.active && mapTouches.length < this.minTouches) {
56
35
  this.reset();
57
36
  }
58
- }, {
59
- key: "isEnabled",
60
- value: function isEnabled() {
61
- return this.enabled;
62
- }
63
- }, {
64
- key: "isActive",
65
- value: function isActive() {
66
- return this.active;
37
+ }
38
+ touchcancel() {
39
+ this.reset();
40
+ }
41
+ enable() {
42
+ this.enabled = true;
43
+ }
44
+ disable() {
45
+ this.enabled = false;
46
+ this.reset();
47
+ }
48
+ isEnabled() {
49
+ return this.enabled;
50
+ }
51
+ isActive() {
52
+ return this.active;
53
+ }
54
+ calculateTransform(e, points, mapTouches) {
55
+ if (mapTouches.length > 0) {
56
+ this.active = true;
67
57
  }
68
- }, {
69
- key: "calculateTransform",
70
- value: function calculateTransform(e, points, mapTouches) {
71
- if (mapTouches.length > 0) {
72
- this.active = true;
73
- }
74
- var touches = indexTouches(mapTouches, points);
75
- var touchPointSum = new Point(0, 0);
76
- var touchDeltaSum = new Point(0, 0);
77
- var touchDeltaCount = 0;
78
- for (var identifier in touches) {
79
- if (touches[identifier]) {
80
- var point = touches[identifier];
81
- var prevPoint = this.touches[identifier];
82
- if (prevPoint) {
83
- touchPointSum._add(point);
84
- touchDeltaSum._add(point.sub(prevPoint));
85
- touchDeltaCount++;
86
- touches[identifier] = point;
87
- }
58
+ const touches = indexTouches(mapTouches, points);
59
+ const touchPointSum = new Point(0, 0);
60
+ const touchDeltaSum = new Point(0, 0);
61
+ let touchDeltaCount = 0;
62
+ for (const identifier in touches) {
63
+ if (touches[identifier]) {
64
+ const point = touches[identifier];
65
+ const prevPoint = this.touches[identifier];
66
+ if (prevPoint) {
67
+ touchPointSum._add(point);
68
+ touchDeltaSum._add(point.sub(prevPoint));
69
+ touchDeltaCount++;
70
+ touches[identifier] = point;
88
71
  }
89
72
  }
90
- this.touches = touches;
91
- if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
92
- return;
93
- }
94
- // @ts-ignore
95
- var panDelta = touchDeltaSum.div(touchDeltaCount);
96
- this.sum._add(panDelta);
97
- if (this.sum.mag() < this.clickTolerance) {
98
- return;
99
- }
100
- // @ts-ignore
101
- var around = touchPointSum.div(touchDeltaCount);
102
- return {
103
- around: around,
104
- panDelta: panDelta
105
- };
106
73
  }
107
- }]);
108
- return TouchPanHandler;
109
- }();
110
- export { TouchPanHandler as default };
74
+ this.touches = touches;
75
+ if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
76
+ return;
77
+ }
78
+ // @ts-ignore
79
+ const panDelta = touchDeltaSum.div(touchDeltaCount);
80
+ this.sum._add(panDelta);
81
+ if (this.sum.mag() < this.clickTolerance) {
82
+ return;
83
+ }
84
+ // @ts-ignore
85
+ const around = touchPointSum.div(touchDeltaCount);
86
+ return {
87
+ around,
88
+ panDelta
89
+ };
90
+ }
91
+ }