@antv/l7-map 2.21.1 → 2.21.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 (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 -5
  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 -42
  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 -6
  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 -41
  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,62 +1,56 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
9
  var _single_tap_recognizer = _interopRequireWildcard(require("./single_tap_recognizer"));
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
12
  // @ts-ignore
15
- var TapRecognizer = exports.default = /*#__PURE__*/function () {
16
- function TapRecognizer(options) {
17
- (0, _classCallCheck2.default)(this, TapRecognizer);
13
+
14
+ class TapRecognizer {
15
+ constructor(options) {
16
+ (0, _defineProperty2.default)(this, "singleTap", void 0);
17
+ (0, _defineProperty2.default)(this, "numTaps", void 0);
18
+ (0, _defineProperty2.default)(this, "lastTime", void 0);
19
+ (0, _defineProperty2.default)(this, "lastTap", void 0);
20
+ (0, _defineProperty2.default)(this, "count", void 0);
18
21
  this.singleTap = new _single_tap_recognizer.default(options);
19
22
  this.numTaps = options.numTaps;
20
23
  this.reset();
21
24
  }
22
- (0, _createClass2.default)(TapRecognizer, [{
23
- key: "reset",
24
- value: function reset() {
25
- this.lastTime = Infinity;
26
- // @ts-ignore
27
- delete this.lastTap;
28
- this.count = 0;
29
- this.singleTap.reset();
30
- }
31
- }, {
32
- key: "touchstart",
33
- value: function touchstart(e, points, mapTouches) {
34
- this.singleTap.touchstart(e, points, mapTouches);
35
- }
36
- }, {
37
- key: "touchmove",
38
- value: function touchmove(e, points, mapTouches) {
39
- this.singleTap.touchmove(e, points, mapTouches);
40
- }
41
- }, {
42
- key: "touchend",
43
- value: function touchend(e, points, mapTouches) {
44
- var tap = this.singleTap.touchend(e, points, mapTouches);
45
- if (tap) {
46
- var soonEnough = e.timeStamp - this.lastTime < _single_tap_recognizer.MAX_TAP_INTERVAL;
47
- var closeEnough = !this.lastTap || this.lastTap.dist(tap) < _single_tap_recognizer.MAX_DIST;
48
- if (!soonEnough || !closeEnough) {
49
- this.reset();
50
- }
51
- this.count++;
52
- this.lastTime = e.timeStamp;
53
- this.lastTap = tap;
54
- if (this.count === this.numTaps) {
55
- this.reset();
56
- return tap;
57
- }
25
+ reset() {
26
+ this.lastTime = Infinity;
27
+ // @ts-ignore
28
+ delete this.lastTap;
29
+ this.count = 0;
30
+ this.singleTap.reset();
31
+ }
32
+ touchstart(e, points, mapTouches) {
33
+ this.singleTap.touchstart(e, points, mapTouches);
34
+ }
35
+ touchmove(e, points, mapTouches) {
36
+ this.singleTap.touchmove(e, points, mapTouches);
37
+ }
38
+ touchend(e, points, mapTouches) {
39
+ const tap = this.singleTap.touchend(e, points, mapTouches);
40
+ if (tap) {
41
+ const soonEnough = e.timeStamp - this.lastTime < _single_tap_recognizer.MAX_TAP_INTERVAL;
42
+ const closeEnough = !this.lastTap || this.lastTap.dist(tap) < _single_tap_recognizer.MAX_DIST;
43
+ if (!soonEnough || !closeEnough) {
44
+ this.reset();
45
+ }
46
+ this.count++;
47
+ this.lastTime = e.timeStamp;
48
+ this.lastTap = tap;
49
+ if (this.count === this.numTaps) {
50
+ this.reset();
51
+ return tap;
58
52
  }
59
53
  }
60
- }]);
61
- return TapRecognizer;
62
- }();
54
+ }
55
+ }
56
+ exports.default = TapRecognizer;
@@ -0,0 +1,22 @@
1
+ import type { EarthMap } from '../../earthmap';
2
+ import type Point from '../../geo/point';
3
+ import type { Map } from '../../map';
4
+ import TapRecognizer from './tap_recognizer';
5
+ export default class TapZoomHandler {
6
+ enabled: boolean;
7
+ active: boolean;
8
+ zoomIn: TapRecognizer;
9
+ zoomOut: TapRecognizer;
10
+ constructor();
11
+ reset(): void;
12
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
13
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
14
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
15
+ cameraAnimation: (map: Map | EarthMap) => Map | EarthMap;
16
+ } | undefined;
17
+ touchcancel(): void;
18
+ enable(): void;
19
+ disable(): void;
20
+ isEnabled(): boolean;
21
+ isActive(): boolean;
22
+ }
@@ -5,13 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
11
10
  // @ts-ignore
12
- var TapZoomHandler = exports.default = /*#__PURE__*/function () {
13
- function TapZoomHandler() {
14
- (0, _classCallCheck2.default)(this, TapZoomHandler);
11
+
12
+ class TapZoomHandler {
13
+ constructor() {
14
+ (0, _defineProperty2.default)(this, "enabled", void 0);
15
+ (0, _defineProperty2.default)(this, "active", void 0);
16
+ (0, _defineProperty2.default)(this, "zoomIn", void 0);
17
+ (0, _defineProperty2.default)(this, "zoomOut", void 0);
15
18
  this.zoomIn = new _tap_recognizer.default({
16
19
  numTouches: 1,
17
20
  numTaps: 2
@@ -22,93 +25,65 @@ var TapZoomHandler = exports.default = /*#__PURE__*/function () {
22
25
  });
23
26
  this.reset();
24
27
  }
25
- (0, _createClass2.default)(TapZoomHandler, [{
26
- key: "reset",
27
- value: function reset() {
28
- this.active = false;
29
- this.zoomIn.reset();
30
- this.zoomOut.reset();
31
- }
32
- }, {
33
- key: "touchstart",
34
- value: function touchstart(e, points, mapTouches) {
35
- this.zoomIn.touchstart(e, points, mapTouches);
36
- this.zoomOut.touchstart(e, points, mapTouches);
37
- }
38
- }, {
39
- key: "touchmove",
40
- value: function touchmove(e, points, mapTouches) {
41
- this.zoomIn.touchmove(e, points, mapTouches);
42
- this.zoomOut.touchmove(e, points, mapTouches);
43
- }
44
- }, {
45
- key: "touchend",
46
- value: function touchend(e, points, mapTouches) {
47
- var _this = this;
48
- var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
49
- var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
50
- if (zoomInPoint) {
51
- this.active = true;
52
- e.preventDefault();
53
- setTimeout(function () {
54
- return _this.reset();
55
- }, 0);
56
- return {
57
- cameraAnimation: function cameraAnimation(map) {
58
- return map.easeTo({
59
- duration: 300,
60
- zoom: map.getZoom() + 1,
61
- around: map.unproject(zoomInPoint)
62
- }, {
63
- originalEvent: e
64
- });
65
- }
66
- };
67
- } else if (zoomOutPoint) {
68
- this.active = true;
69
- e.preventDefault();
70
- setTimeout(function () {
71
- return _this.reset();
72
- }, 0);
73
- return {
74
- cameraAnimation: function cameraAnimation(map) {
75
- return map.easeTo({
76
- duration: 300,
77
- zoom: map.getZoom() - 1,
78
- around: map.unproject(zoomOutPoint)
79
- }, {
80
- originalEvent: e
81
- });
82
- }
83
- };
84
- }
85
- }
86
- }, {
87
- key: "touchcancel",
88
- value: function touchcancel() {
89
- this.reset();
90
- }
91
- }, {
92
- key: "enable",
93
- value: function enable() {
94
- this.enabled = true;
95
- }
96
- }, {
97
- key: "disable",
98
- value: function disable() {
99
- this.enabled = false;
100
- this.reset();
101
- }
102
- }, {
103
- key: "isEnabled",
104
- value: function isEnabled() {
105
- return this.enabled;
106
- }
107
- }, {
108
- key: "isActive",
109
- value: function isActive() {
110
- return this.active;
28
+ reset() {
29
+ this.active = false;
30
+ this.zoomIn.reset();
31
+ this.zoomOut.reset();
32
+ }
33
+ touchstart(e, points, mapTouches) {
34
+ this.zoomIn.touchstart(e, points, mapTouches);
35
+ this.zoomOut.touchstart(e, points, mapTouches);
36
+ }
37
+ touchmove(e, points, mapTouches) {
38
+ this.zoomIn.touchmove(e, points, mapTouches);
39
+ this.zoomOut.touchmove(e, points, mapTouches);
40
+ }
41
+ touchend(e, points, mapTouches) {
42
+ const zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
43
+ const zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
44
+ if (zoomInPoint) {
45
+ this.active = true;
46
+ e.preventDefault();
47
+ setTimeout(() => this.reset(), 0);
48
+ return {
49
+ cameraAnimation: map => map.easeTo({
50
+ duration: 300,
51
+ zoom: map.getZoom() + 1,
52
+ around: map.unproject(zoomInPoint)
53
+ }, {
54
+ originalEvent: e
55
+ })
56
+ };
57
+ } else if (zoomOutPoint) {
58
+ this.active = true;
59
+ e.preventDefault();
60
+ setTimeout(() => this.reset(), 0);
61
+ return {
62
+ cameraAnimation: map => map.easeTo({
63
+ duration: 300,
64
+ zoom: map.getZoom() - 1,
65
+ around: map.unproject(zoomOutPoint)
66
+ }, {
67
+ originalEvent: e
68
+ })
69
+ };
111
70
  }
112
- }]);
113
- return TapZoomHandler;
114
- }();
71
+ }
72
+ touchcancel() {
73
+ this.reset();
74
+ }
75
+ enable() {
76
+ this.enabled = true;
77
+ }
78
+ disable() {
79
+ this.enabled = false;
80
+ this.reset();
81
+ }
82
+ isEnabled() {
83
+ return this.enabled;
84
+ }
85
+ isActive() {
86
+ return this.active;
87
+ }
88
+ }
89
+ exports.default = TapZoomHandler;
@@ -0,0 +1,5 @@
1
+ import TouchPanHandler from './touch_pan';
2
+ import TouchPitchHandler from './touch_pitch';
3
+ import TouchRotateHandler from './touch_rotate';
4
+ import TouchZoomHandler from './touch_zoom';
5
+ export { TouchPanHandler, TouchPitchHandler, TouchRotateHandler, TouchZoomHandler, };
@@ -6,25 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  Object.defineProperty(exports, "TouchPanHandler", {
8
8
  enumerable: true,
9
- get: function get() {
9
+ get: function () {
10
10
  return _touch_pan.default;
11
11
  }
12
12
  });
13
13
  Object.defineProperty(exports, "TouchPitchHandler", {
14
14
  enumerable: true,
15
- get: function get() {
15
+ get: function () {
16
16
  return _touch_pitch.default;
17
17
  }
18
18
  });
19
19
  Object.defineProperty(exports, "TouchRotateHandler", {
20
20
  enumerable: true,
21
- get: function get() {
21
+ get: function () {
22
22
  return _touch_rotate.default;
23
23
  }
24
24
  });
25
25
  Object.defineProperty(exports, "TouchZoomHandler", {
26
26
  enumerable: true,
27
- get: function get() {
27
+ get: function () {
28
28
  return _touch_zoom.default;
29
29
  }
30
30
  });
@@ -0,0 +1,30 @@
1
+ import Point from '../../geo/point';
2
+ export default class TouchPanHandler {
3
+ enabled: boolean;
4
+ active: boolean;
5
+ touches: {
6
+ [key: string]: Point;
7
+ };
8
+ minTouches: number;
9
+ clickTolerance: number;
10
+ sum: Point;
11
+ constructor(options: {
12
+ clickTolerance: number;
13
+ });
14
+ reset(): void;
15
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
16
+ around: Point;
17
+ panDelta: Point;
18
+ } | undefined;
19
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
20
+ around: Point;
21
+ panDelta: Point;
22
+ } | undefined;
23
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
24
+ touchcancel(): void;
25
+ enable(): void;
26
+ disable(): void;
27
+ isEnabled(): boolean;
28
+ isActive(): boolean;
29
+ private calculateTransform;
30
+ }
@@ -5,112 +5,96 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _point = _interopRequireDefault(require("../../geo/point"));
11
10
  var _handler_util = require("../handler_util");
12
11
  // @ts-ignore
13
- var TouchPanHandler = exports.default = /*#__PURE__*/function () {
14
- function TouchPanHandler(options) {
15
- (0, _classCallCheck2.default)(this, TouchPanHandler);
12
+
13
+ class TouchPanHandler {
14
+ constructor(options) {
15
+ (0, _defineProperty2.default)(this, "enabled", void 0);
16
+ (0, _defineProperty2.default)(this, "active", void 0);
17
+ (0, _defineProperty2.default)(this, "touches", void 0);
18
+ (0, _defineProperty2.default)(this, "minTouches", void 0);
19
+ (0, _defineProperty2.default)(this, "clickTolerance", void 0);
20
+ (0, _defineProperty2.default)(this, "sum", void 0);
16
21
  this.minTouches = 1;
17
22
  this.clickTolerance = options.clickTolerance || 1;
18
23
  this.reset();
19
24
  }
20
- (0, _createClass2.default)(TouchPanHandler, [{
21
- key: "reset",
22
- value: function reset() {
23
- this.active = false;
24
- this.touches = {};
25
- this.sum = new _point.default(0, 0);
26
- }
27
- }, {
28
- key: "touchstart",
29
- value: function touchstart(e, points, mapTouches) {
30
- return this.calculateTransform(e, points, mapTouches);
31
- }
32
- }, {
33
- key: "touchmove",
34
- value: function touchmove(e, points, mapTouches) {
35
- if (!this.active) {
36
- return;
37
- }
38
- e.preventDefault();
39
- return this.calculateTransform(e, points, mapTouches);
40
- }
41
- }, {
42
- key: "touchend",
43
- value: function touchend(e, points, mapTouches) {
44
- this.calculateTransform(e, points, mapTouches);
45
- if (this.active && mapTouches.length < this.minTouches) {
46
- this.reset();
47
- }
48
- }
49
- }, {
50
- key: "touchcancel",
51
- value: function touchcancel() {
52
- this.reset();
53
- }
54
- }, {
55
- key: "enable",
56
- value: function enable() {
57
- this.enabled = true;
25
+ reset() {
26
+ this.active = false;
27
+ this.touches = {};
28
+ this.sum = new _point.default(0, 0);
29
+ }
30
+ touchstart(e, points, mapTouches) {
31
+ return this.calculateTransform(e, points, mapTouches);
32
+ }
33
+ touchmove(e, points, mapTouches) {
34
+ if (!this.active) {
35
+ return;
58
36
  }
59
- }, {
60
- key: "disable",
61
- value: function disable() {
62
- this.enabled = false;
37
+ e.preventDefault();
38
+ return this.calculateTransform(e, points, mapTouches);
39
+ }
40
+ touchend(e, points, mapTouches) {
41
+ this.calculateTransform(e, points, mapTouches);
42
+ if (this.active && mapTouches.length < this.minTouches) {
63
43
  this.reset();
64
44
  }
65
- }, {
66
- key: "isEnabled",
67
- value: function isEnabled() {
68
- return this.enabled;
69
- }
70
- }, {
71
- key: "isActive",
72
- value: function isActive() {
73
- return this.active;
45
+ }
46
+ touchcancel() {
47
+ this.reset();
48
+ }
49
+ enable() {
50
+ this.enabled = true;
51
+ }
52
+ disable() {
53
+ this.enabled = false;
54
+ this.reset();
55
+ }
56
+ isEnabled() {
57
+ return this.enabled;
58
+ }
59
+ isActive() {
60
+ return this.active;
61
+ }
62
+ calculateTransform(e, points, mapTouches) {
63
+ if (mapTouches.length > 0) {
64
+ this.active = true;
74
65
  }
75
- }, {
76
- key: "calculateTransform",
77
- value: function calculateTransform(e, points, mapTouches) {
78
- if (mapTouches.length > 0) {
79
- this.active = true;
80
- }
81
- var touches = (0, _handler_util.indexTouches)(mapTouches, points);
82
- var touchPointSum = new _point.default(0, 0);
83
- var touchDeltaSum = new _point.default(0, 0);
84
- var touchDeltaCount = 0;
85
- for (var identifier in touches) {
86
- if (touches[identifier]) {
87
- var point = touches[identifier];
88
- var prevPoint = this.touches[identifier];
89
- if (prevPoint) {
90
- touchPointSum._add(point);
91
- touchDeltaSum._add(point.sub(prevPoint));
92
- touchDeltaCount++;
93
- touches[identifier] = point;
94
- }
66
+ const touches = (0, _handler_util.indexTouches)(mapTouches, points);
67
+ const touchPointSum = new _point.default(0, 0);
68
+ const touchDeltaSum = new _point.default(0, 0);
69
+ let touchDeltaCount = 0;
70
+ for (const identifier in touches) {
71
+ if (touches[identifier]) {
72
+ const point = touches[identifier];
73
+ const prevPoint = this.touches[identifier];
74
+ if (prevPoint) {
75
+ touchPointSum._add(point);
76
+ touchDeltaSum._add(point.sub(prevPoint));
77
+ touchDeltaCount++;
78
+ touches[identifier] = point;
95
79
  }
96
80
  }
97
- this.touches = touches;
98
- if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
99
- return;
100
- }
101
- // @ts-ignore
102
- var panDelta = touchDeltaSum.div(touchDeltaCount);
103
- this.sum._add(panDelta);
104
- if (this.sum.mag() < this.clickTolerance) {
105
- return;
106
- }
107
- // @ts-ignore
108
- var around = touchPointSum.div(touchDeltaCount);
109
- return {
110
- around: around,
111
- panDelta: panDelta
112
- };
113
81
  }
114
- }]);
115
- return TouchPanHandler;
116
- }();
82
+ this.touches = touches;
83
+ if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
84
+ return;
85
+ }
86
+ // @ts-ignore
87
+ const panDelta = touchDeltaSum.div(touchDeltaCount);
88
+ this.sum._add(panDelta);
89
+ if (this.sum.mag() < this.clickTolerance) {
90
+ return;
91
+ }
92
+ // @ts-ignore
93
+ const around = touchPointSum.div(touchDeltaCount);
94
+ return {
95
+ around,
96
+ panDelta
97
+ };
98
+ }
99
+ }
100
+ exports.default = TouchPanHandler;
@@ -0,0 +1,13 @@
1
+ import type Point from '../../geo/point';
2
+ import TwoTouchHandler from './two_touch';
3
+ export default class TouchPitchHandler extends TwoTouchHandler {
4
+ valid: boolean | void;
5
+ firstMove: number;
6
+ lastPoints: [Point, Point];
7
+ reset(): void;
8
+ start(points: [Point, Point]): void;
9
+ move(points: [Point, Point], center: Point, e: TouchEvent): {
10
+ pitchDelta: number;
11
+ } | undefined;
12
+ gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number): boolean | undefined;
13
+ }