@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
@@ -5,8 +5,7 @@ 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
  /**
11
10
  * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
12
11
  * pinching on a touchscreen.
@@ -14,12 +13,17 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
14
13
  * They can zoom with one finger by double tapping and dragging. On the second tap,
15
14
  * hold the finger down and drag up or down to zoom in or out.
16
15
  */
17
- var TouchZoomRotateHandler = exports.default = /*#__PURE__*/function () {
16
+ class TouchZoomRotateHandler {
18
17
  /**
19
18
  * @private
20
19
  */
21
- function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
22
- (0, _classCallCheck2.default)(this, TouchZoomRotateHandler);
20
+ constructor(el, touchZoom, touchRotate, tapDragZoom) {
21
+ (0, _defineProperty2.default)(this, "el", void 0);
22
+ (0, _defineProperty2.default)(this, "touchZoom", void 0);
23
+ (0, _defineProperty2.default)(this, "touchRotate", void 0);
24
+ (0, _defineProperty2.default)(this, "tapDragZoom", void 0);
25
+ (0, _defineProperty2.default)(this, "rotationDisabled", void 0);
26
+ (0, _defineProperty2.default)(this, "enabled", void 0);
23
27
  this.el = el;
24
28
  this.touchZoom = touchZoom;
25
29
  this.touchRotate = touchRotate;
@@ -39,83 +43,70 @@ var TouchZoomRotateHandler = exports.default = /*#__PURE__*/function () {
39
43
  * @example
40
44
  * map.touchZoomRotate.enable({ around: 'center' });
41
45
  */
42
- (0, _createClass2.default)(TouchZoomRotateHandler, [{
43
- key: "enable",
44
- value: function enable(options) {
45
- this.touchZoom.enable(options);
46
- if (!this.rotationDisabled) {
47
- this.touchRotate.enable(options);
48
- }
49
- this.tapDragZoom.enable();
50
- this.el.classList.add('l7-touch-zoom-rotate');
46
+ enable(options) {
47
+ this.touchZoom.enable(options);
48
+ if (!this.rotationDisabled) {
49
+ this.touchRotate.enable(options);
51
50
  }
51
+ this.tapDragZoom.enable();
52
+ this.el.classList.add('l7-touch-zoom-rotate');
53
+ }
52
54
 
53
- /**
54
- * Disables the "pinch to rotate and zoom" interaction.
55
- *
56
- * @example
57
- * map.touchZoomRotate.disable();
58
- */
59
- }, {
60
- key: "disable",
61
- value: function disable() {
62
- this.touchZoom.disable();
63
- this.touchRotate.disable();
64
- this.tapDragZoom.disable();
65
- this.el.classList.remove('l7-touch-zoom-rotate');
66
- }
55
+ /**
56
+ * Disables the "pinch to rotate and zoom" interaction.
57
+ *
58
+ * @example
59
+ * map.touchZoomRotate.disable();
60
+ */
61
+ disable() {
62
+ this.touchZoom.disable();
63
+ this.touchRotate.disable();
64
+ this.tapDragZoom.disable();
65
+ this.el.classList.remove('l7-touch-zoom-rotate');
66
+ }
67
67
 
68
- /**
69
- * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
70
- *
71
- * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
72
- */
73
- }, {
74
- key: "isEnabled",
75
- value: function isEnabled() {
76
- return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
77
- }
68
+ /**
69
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
70
+ *
71
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
72
+ */
73
+ isEnabled() {
74
+ return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
75
+ }
78
76
 
79
- /**
80
- * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
81
- *
82
- * @returns {boolean} //eslint-disable-line
83
- */
84
- }, {
85
- key: "isActive",
86
- value: function isActive() {
87
- return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
88
- }
77
+ /**
78
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
79
+ *
80
+ * @returns {boolean} //eslint-disable-line
81
+ */
82
+ isActive() {
83
+ return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
84
+ }
89
85
 
90
- /**
91
- * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
92
- * interaction enabled.
93
- *
94
- * @example
95
- * map.touchZoomRotate.disableRotation();
96
- */
97
- }, {
98
- key: "disableRotation",
99
- value: function disableRotation() {
100
- this.rotationDisabled = true;
101
- this.touchRotate.disable();
102
- }
86
+ /**
87
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
88
+ * interaction enabled.
89
+ *
90
+ * @example
91
+ * map.touchZoomRotate.disableRotation();
92
+ */
93
+ disableRotation() {
94
+ this.rotationDisabled = true;
95
+ this.touchRotate.disable();
96
+ }
103
97
 
104
- /**
105
- * Enables the "pinch to rotate" interaction.
106
- *
107
- * @example
108
- * map.touchZoomRotate.enable();
109
- * map.touchZoomRotate.enableRotation();
110
- */
111
- }, {
112
- key: "enableRotation",
113
- value: function enableRotation() {
114
- this.rotationDisabled = false;
115
- if (this.touchZoom.isEnabled()) {
116
- this.touchRotate.enable();
117
- }
98
+ /**
99
+ * Enables the "pinch to rotate" interaction.
100
+ *
101
+ * @example
102
+ * map.touchZoomRotate.enable();
103
+ * map.touchZoomRotate.enableRotation();
104
+ */
105
+ enableRotation() {
106
+ this.rotationDisabled = false;
107
+ if (this.touchZoom.isEnabled()) {
108
+ this.touchRotate.enable();
118
109
  }
119
- }]);
120
- return TouchZoomRotateHandler;
121
- }();
110
+ }
111
+ }
112
+ exports.default = TouchZoomRotateHandler;
@@ -0,0 +1,20 @@
1
+ import Point from '../../geo/point';
2
+ export declare const MAX_TAP_INTERVAL = 500;
3
+ export declare const MAX_TOUCH_TIME = 500;
4
+ export declare const MAX_DIST = 30;
5
+ export default class SingleTapRecognizer {
6
+ numTouches: number;
7
+ centroid: Point;
8
+ startTime: number;
9
+ aborted: boolean;
10
+ touches: {
11
+ [key: string]: Point;
12
+ };
13
+ constructor(options: {
14
+ numTouches: number;
15
+ });
16
+ reset(): void;
17
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
18
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
19
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
20
+ }
@@ -5,98 +5,82 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.MAX_TOUCH_TIME = exports.MAX_TAP_INTERVAL = exports.MAX_DIST = 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
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } // @ts-ignore
11
+ // @ts-ignore
12
+
15
13
  function getCentroid(points) {
16
- var sum = new _point.default(0, 0);
17
- var _iterator = _createForOfIteratorHelper(points),
18
- _step;
19
- try {
20
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
21
- var point = _step.value;
22
- sum._add(point);
23
- }
24
- // @ts-ignore
25
- } catch (err) {
26
- _iterator.e(err);
27
- } finally {
28
- _iterator.f();
14
+ const sum = new _point.default(0, 0);
15
+ for (const point of points) {
16
+ sum._add(point);
29
17
  }
18
+ // @ts-ignore
30
19
  return sum.div(points.length);
31
20
  }
32
- var MAX_TAP_INTERVAL = exports.MAX_TAP_INTERVAL = 500;
33
- var MAX_TOUCH_TIME = exports.MAX_TOUCH_TIME = 500;
34
- var MAX_DIST = exports.MAX_DIST = 30;
35
- var SingleTapRecognizer = exports.default = /*#__PURE__*/function () {
36
- function SingleTapRecognizer(options) {
37
- (0, _classCallCheck2.default)(this, SingleTapRecognizer);
21
+ const MAX_TAP_INTERVAL = exports.MAX_TAP_INTERVAL = 500;
22
+ const MAX_TOUCH_TIME = exports.MAX_TOUCH_TIME = 500;
23
+ const MAX_DIST = exports.MAX_DIST = 30;
24
+ class SingleTapRecognizer {
25
+ constructor(options) {
26
+ (0, _defineProperty2.default)(this, "numTouches", void 0);
27
+ (0, _defineProperty2.default)(this, "centroid", void 0);
28
+ (0, _defineProperty2.default)(this, "startTime", void 0);
29
+ (0, _defineProperty2.default)(this, "aborted", void 0);
30
+ (0, _defineProperty2.default)(this, "touches", void 0);
38
31
  this.reset();
39
32
  this.numTouches = options.numTouches;
40
33
  }
41
- (0, _createClass2.default)(SingleTapRecognizer, [{
42
- key: "reset",
43
- value: function reset() {
44
- // @ts-ignore
45
- delete this.centroid;
46
- // @ts-ignore
47
- delete this.startTime;
48
- // @ts-ignore
49
- delete this.touches;
50
- this.aborted = false;
34
+ reset() {
35
+ // @ts-ignore
36
+ delete this.centroid;
37
+ // @ts-ignore
38
+ delete this.startTime;
39
+ // @ts-ignore
40
+ delete this.touches;
41
+ this.aborted = false;
42
+ }
43
+ touchstart(e, points, mapTouches) {
44
+ if (this.centroid || mapTouches.length > this.numTouches) {
45
+ this.aborted = true;
51
46
  }
52
- }, {
53
- key: "touchstart",
54
- value: function touchstart(e, points, mapTouches) {
55
- if (this.centroid || mapTouches.length > this.numTouches) {
56
- this.aborted = true;
57
- }
58
- if (this.aborted) {
59
- return;
60
- }
61
- if (this.startTime === undefined) {
62
- this.startTime = e.timeStamp;
63
- }
64
- if (mapTouches.length === this.numTouches) {
65
- this.centroid = getCentroid(points);
66
- this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
67
- }
47
+ if (this.aborted) {
48
+ return;
68
49
  }
69
- }, {
70
- key: "touchmove",
71
- value: function touchmove(e, points, mapTouches) {
72
- if (this.aborted || !this.centroid) {
73
- return;
74
- }
75
- var newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
76
- for (var id in this.touches) {
77
- if (this.touches[id]) {
78
- var prevPos = this.touches[id];
79
- var pos = newTouches[id];
80
- if (!pos || pos.dist(prevPos) > MAX_DIST) {
81
- this.aborted = true;
82
- }
50
+ if (this.startTime === undefined) {
51
+ this.startTime = e.timeStamp;
52
+ }
53
+ if (mapTouches.length === this.numTouches) {
54
+ this.centroid = getCentroid(points);
55
+ this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
56
+ }
57
+ }
58
+ touchmove(e, points, mapTouches) {
59
+ if (this.aborted || !this.centroid) {
60
+ return;
61
+ }
62
+ const newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
63
+ for (const id in this.touches) {
64
+ if (this.touches[id]) {
65
+ const prevPos = this.touches[id];
66
+ const pos = newTouches[id];
67
+ if (!pos || pos.dist(prevPos) > MAX_DIST) {
68
+ this.aborted = true;
83
69
  }
84
70
  }
85
71
  }
86
- }, {
87
- key: "touchend",
88
- value: function touchend(e, points, mapTouches) {
89
- if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
90
- this.aborted = true;
91
- }
92
- if (mapTouches.length === 0) {
93
- var centroid = !this.aborted && this.centroid;
94
- this.reset();
95
- if (centroid) {
96
- return centroid;
97
- }
72
+ }
73
+ touchend(e, points, mapTouches) {
74
+ if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
75
+ this.aborted = true;
76
+ }
77
+ if (mapTouches.length === 0) {
78
+ const centroid = !this.aborted && this.centroid;
79
+ this.reset();
80
+ if (centroid) {
81
+ return centroid;
98
82
  }
99
83
  }
100
- }]);
101
- return SingleTapRecognizer;
102
- }();
84
+ }
85
+ }
86
+ exports.default = SingleTapRecognizer;
@@ -0,0 +1,22 @@
1
+ import type Point from '../../geo/point';
2
+ import TapRecognizer from './tap_recognizer';
3
+ export default class TapDragZoomHandler {
4
+ enabled: boolean;
5
+ active: boolean;
6
+ swipePoint: Point;
7
+ swipeTouch: number;
8
+ tapTime: number;
9
+ tap: TapRecognizer;
10
+ constructor();
11
+ reset(): void;
12
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
13
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
14
+ zoomDelta: number;
15
+ } | undefined;
16
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
17
+ touchcancel(): void;
18
+ enable(): void;
19
+ disable(): void;
20
+ isEnabled(): boolean;
21
+ isActive(): boolean;
22
+ }
@@ -5,107 +5,93 @@ 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 _single_tap_recognizer = require("./single_tap_recognizer");
11
10
  var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
12
11
  // @ts-ignore
13
- var TapDragZoomHandler = exports.default = /*#__PURE__*/function () {
14
- function TapDragZoomHandler() {
15
- (0, _classCallCheck2.default)(this, TapDragZoomHandler);
12
+
13
+ class TapDragZoomHandler {
14
+ constructor() {
15
+ (0, _defineProperty2.default)(this, "enabled", void 0);
16
+ (0, _defineProperty2.default)(this, "active", void 0);
17
+ (0, _defineProperty2.default)(this, "swipePoint", void 0);
18
+ (0, _defineProperty2.default)(this, "swipeTouch", void 0);
19
+ (0, _defineProperty2.default)(this, "tapTime", void 0);
20
+ (0, _defineProperty2.default)(this, "tap", void 0);
16
21
  this.tap = new _tap_recognizer.default({
17
22
  numTouches: 1,
18
23
  numTaps: 1
19
24
  });
20
25
  this.reset();
21
26
  }
22
- (0, _createClass2.default)(TapDragZoomHandler, [{
23
- key: "reset",
24
- value: function reset() {
25
- this.active = false;
26
- // @ts-ignore
27
- delete this.swipePoint;
28
- // @ts-ignore
29
- delete this.swipeTouch;
30
- // @ts-ignore
31
- delete this.tapTime;
32
- this.tap.reset();
27
+ reset() {
28
+ this.active = false;
29
+ // @ts-ignore
30
+ delete this.swipePoint;
31
+ // @ts-ignore
32
+ delete this.swipeTouch;
33
+ // @ts-ignore
34
+ delete this.tapTime;
35
+ this.tap.reset();
36
+ }
37
+ touchstart(e, points, mapTouches) {
38
+ if (this.swipePoint) {
39
+ return;
40
+ }
41
+ if (this.tapTime && e.timeStamp - this.tapTime > _single_tap_recognizer.MAX_TAP_INTERVAL) {
42
+ this.reset();
33
43
  }
34
- }, {
35
- key: "touchstart",
36
- value: function touchstart(e, points, mapTouches) {
37
- if (this.swipePoint) {
44
+ if (!this.tapTime) {
45
+ this.tap.touchstart(e, points, mapTouches);
46
+ } else if (mapTouches.length > 0) {
47
+ this.swipePoint = points[0];
48
+ this.swipeTouch = mapTouches[0].identifier;
49
+ }
50
+ }
51
+ touchmove(e, points, mapTouches) {
52
+ if (!this.tapTime) {
53
+ this.tap.touchmove(e, points, mapTouches);
54
+ } else if (this.swipePoint) {
55
+ if (mapTouches[0].identifier !== this.swipeTouch) {
38
56
  return;
39
57
  }
40
- if (this.tapTime && e.timeStamp - this.tapTime > _single_tap_recognizer.MAX_TAP_INTERVAL) {
41
- this.reset();
42
- }
43
- if (!this.tapTime) {
44
- this.tap.touchstart(e, points, mapTouches);
45
- } else if (mapTouches.length > 0) {
46
- this.swipePoint = points[0];
47
- this.swipeTouch = mapTouches[0].identifier;
48
- }
58
+ const newSwipePoint = points[0];
59
+ const dist = newSwipePoint.y - this.swipePoint.y;
60
+ this.swipePoint = newSwipePoint;
61
+ e.preventDefault();
62
+ this.active = true;
63
+ return {
64
+ zoomDelta: dist / 128
65
+ };
49
66
  }
50
- }, {
51
- key: "touchmove",
52
- value: function touchmove(e, points, mapTouches) {
53
- if (!this.tapTime) {
54
- this.tap.touchmove(e, points, mapTouches);
55
- } else if (this.swipePoint) {
56
- if (mapTouches[0].identifier !== this.swipeTouch) {
57
- return;
58
- }
59
- var newSwipePoint = points[0];
60
- var dist = newSwipePoint.y - this.swipePoint.y;
61
- this.swipePoint = newSwipePoint;
62
- e.preventDefault();
63
- this.active = true;
64
- return {
65
- zoomDelta: dist / 128
66
- };
67
+ }
68
+ touchend(e, points, mapTouches) {
69
+ if (!this.tapTime) {
70
+ const point = this.tap.touchend(e, points, mapTouches);
71
+ if (point) {
72
+ this.tapTime = e.timeStamp;
67
73
  }
68
- }
69
- }, {
70
- key: "touchend",
71
- value: function touchend(e, points, mapTouches) {
72
- if (!this.tapTime) {
73
- var point = this.tap.touchend(e, points, mapTouches);
74
- if (point) {
75
- this.tapTime = e.timeStamp;
76
- }
77
- } else if (this.swipePoint) {
78
- if (mapTouches.length === 0) {
79
- this.reset();
80
- }
74
+ } else if (this.swipePoint) {
75
+ if (mapTouches.length === 0) {
76
+ this.reset();
81
77
  }
82
78
  }
83
- }, {
84
- key: "touchcancel",
85
- value: function touchcancel() {
86
- this.reset();
87
- }
88
- }, {
89
- key: "enable",
90
- value: function enable() {
91
- this.enabled = true;
92
- }
93
- }, {
94
- key: "disable",
95
- value: function disable() {
96
- this.enabled = false;
97
- this.reset();
98
- }
99
- }, {
100
- key: "isEnabled",
101
- value: function isEnabled() {
102
- return this.enabled;
103
- }
104
- }, {
105
- key: "isActive",
106
- value: function isActive() {
107
- return this.active;
108
- }
109
- }]);
110
- return TapDragZoomHandler;
111
- }();
79
+ }
80
+ touchcancel() {
81
+ this.reset();
82
+ }
83
+ enable() {
84
+ this.enabled = true;
85
+ }
86
+ disable() {
87
+ this.enabled = false;
88
+ this.reset();
89
+ }
90
+ isEnabled() {
91
+ return this.enabled;
92
+ }
93
+ isActive() {
94
+ return this.active;
95
+ }
96
+ }
97
+ exports.default = TapDragZoomHandler;
@@ -0,0 +1,17 @@
1
+ import type Point from '../../geo/point';
2
+ import SingleTapRecognizer from './single_tap_recognizer';
3
+ export default class TapRecognizer {
4
+ singleTap: SingleTapRecognizer;
5
+ numTaps: number;
6
+ lastTime: number;
7
+ lastTap: Point;
8
+ count: number;
9
+ constructor(options: {
10
+ numTaps: number;
11
+ numTouches: number;
12
+ });
13
+ reset(): void;
14
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
15
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
16
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
17
+ }