@antv/l7-map 2.17.11 → 2.17.12

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 +148 -90
  2. package/es/earthmap.js +65 -13
  3. package/es/geo/edge_insets.js +14 -4
  4. package/es/geo/lng_lat.js +13 -5
  5. package/es/geo/lng_lat_bounds.js +17 -4
  6. package/es/geo/mercator.js +10 -2
  7. package/es/geo/point.js +7 -0
  8. package/es/geo/simple.js +11 -6
  9. package/es/geo/transform.js +132 -127
  10. package/es/handler/blockable_map_event.js +12 -7
  11. package/es/handler/box_zoom.js +30 -10
  12. package/es/handler/click_zoom.js +5 -0
  13. package/es/handler/events/event.js +2 -0
  14. package/es/handler/events/map_mouse_event.js +12 -0
  15. package/es/handler/events/map_touch_event.js +12 -2
  16. package/es/handler/events/map_wheel_event.js +12 -1
  17. package/es/handler/events/render_event.js +13 -0
  18. package/es/handler/handler_inertia.js +34 -6
  19. package/es/handler/handler_manager.js +147 -55
  20. package/es/handler/handler_util.js +2 -1
  21. package/es/handler/keyboard.js +20 -1
  22. package/es/handler/map_event.js +9 -3
  23. package/es/handler/mouse/mouse_handler.js +24 -11
  24. package/es/handler/mouse/mousepan_handler.js +11 -1
  25. package/es/handler/mouse/mousepitch_hander.js +11 -1
  26. package/es/handler/mouse/mouserotate_hander.js +11 -1
  27. package/es/handler/mouse/util.js +3 -2
  28. package/es/handler/scroll_zoom.js +71 -43
  29. package/es/handler/shim/dblclick_zoom.js +9 -4
  30. package/es/handler/shim/drag_pan.js +11 -4
  31. package/es/handler/shim/drag_rotate.js +10 -4
  32. package/es/handler/shim/touch_zoom_rotate.js +16 -6
  33. package/es/handler/tap/single_tap_recognizer.js +31 -8
  34. package/es/handler/tap/tap_drag_zoom.js +15 -7
  35. package/es/handler/tap/tap_recognizer.js +11 -3
  36. package/es/handler/tap/tap_zoom.js +7 -1
  37. package/es/handler/touch/touch_pan.js +22 -4
  38. package/es/handler/touch/touch_pitch.js +27 -10
  39. package/es/handler/touch/touch_rotate.js +19 -8
  40. package/es/handler/touch/touch_zoom.js +18 -5
  41. package/es/handler/touch/two_touch.js +32 -19
  42. package/es/hash.js +31 -9
  43. package/es/map.js +78 -16
  44. package/es/util.js +26 -18
  45. package/es/utils/Aabb.js +31 -10
  46. package/es/utils/dom.js +58 -24
  47. package/es/utils/performance.js +7 -8
  48. package/es/utils/primitives.js +11 -13
  49. package/es/utils/task_queue.js +23 -6
  50. package/lib/camera.js +169 -91
  51. package/lib/earthmap.js +80 -12
  52. package/lib/geo/edge_insets.js +18 -3
  53. package/lib/geo/lng_lat.js +18 -5
  54. package/lib/geo/lng_lat_bounds.js +20 -4
  55. package/lib/geo/mercator.js +22 -1
  56. package/lib/geo/point.js +8 -0
  57. package/lib/geo/simple.js +24 -5
  58. package/lib/geo/transform.js +164 -127
  59. package/lib/handler/blockable_map_event.js +14 -6
  60. package/lib/handler/box_zoom.js +39 -8
  61. package/lib/handler/click_zoom.js +6 -0
  62. package/lib/handler/events/event.js +5 -0
  63. package/lib/handler/events/index.js +4 -0
  64. package/lib/handler/events/map_mouse_event.js +20 -2
  65. package/lib/handler/events/map_touch_event.js +21 -2
  66. package/lib/handler/events/map_wheel_event.js +16 -1
  67. package/lib/handler/events/render_event.js +19 -0
  68. package/lib/handler/handler_inertia.js +37 -5
  69. package/lib/handler/handler_manager.js +171 -56
  70. package/lib/handler/handler_util.js +3 -1
  71. package/lib/handler/keyboard.js +22 -1
  72. package/lib/handler/map_event.js +11 -2
  73. package/lib/handler/mouse/index.js +4 -0
  74. package/lib/handler/mouse/mouse_handler.js +27 -10
  75. package/lib/handler/mouse/mousepan_handler.js +18 -1
  76. package/lib/handler/mouse/mousepitch_hander.js +17 -1
  77. package/lib/handler/mouse/mouserotate_hander.js +17 -1
  78. package/lib/handler/mouse/util.js +6 -2
  79. package/lib/handler/scroll_zoom.js +77 -43
  80. package/lib/handler/shim/dblclick_zoom.js +10 -4
  81. package/lib/handler/shim/drag_pan.js +13 -4
  82. package/lib/handler/shim/drag_rotate.js +11 -4
  83. package/lib/handler/shim/touch_zoom_rotate.js +18 -6
  84. package/lib/handler/tap/single_tap_recognizer.js +33 -8
  85. package/lib/handler/tap/tap_drag_zoom.js +18 -6
  86. package/lib/handler/tap/tap_recognizer.js +17 -2
  87. package/lib/handler/tap/tap_zoom.js +9 -0
  88. package/lib/handler/touch/index.js +5 -0
  89. package/lib/handler/touch/touch_pan.js +25 -4
  90. package/lib/handler/touch/touch_pitch.js +32 -10
  91. package/lib/handler/touch/touch_rotate.js +25 -8
  92. package/lib/handler/touch/touch_zoom.js +24 -5
  93. package/lib/handler/touch/two_touch.js +35 -18
  94. package/lib/hash.js +35 -8
  95. package/lib/index.js +8 -0
  96. package/lib/map.js +95 -15
  97. package/lib/util.js +38 -16
  98. package/lib/utils/Aabb.js +34 -10
  99. package/lib/utils/dom.js +64 -22
  100. package/lib/utils/performance.js +9 -8
  101. package/lib/utils/primitives.js +16 -13
  102. package/lib/utils/task_queue.js +24 -6
  103. package/package.json +3 -3
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _l7Utils = require("@antv/l7-utils");
15
+
11
16
  /**
12
17
  * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
13
18
  * pinching on a touchscreen.
@@ -28,7 +33,6 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
28
33
  this.rotationDisabled = false;
29
34
  this.enabled = true;
30
35
  }
31
-
32
36
  /**
33
37
  * Enables the "pinch to rotate and zoom" interaction.
34
38
  *
@@ -40,58 +44,63 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
40
44
  * @example
41
45
  * map.touchZoomRotate.enable({ around: 'center' });
42
46
  */
47
+
48
+
43
49
  (0, _createClass2.default)(TouchZoomRotateHandler, [{
44
50
  key: "enable",
45
51
  value: function enable(options) {
46
52
  this.touchZoom.enable(options);
53
+
47
54
  if (!this.rotationDisabled) {
48
55
  this.touchRotate.enable(options);
49
56
  }
57
+
50
58
  this.tapDragZoom.enable();
59
+
51
60
  if (!_l7Utils.isMini) {
52
61
  this.el.classList.add('l7-touch-zoom-rotate');
53
62
  }
54
63
  }
55
-
56
64
  /**
57
65
  * Disables the "pinch to rotate and zoom" interaction.
58
66
  *
59
67
  * @example
60
68
  * map.touchZoomRotate.disable();
61
69
  */
70
+
62
71
  }, {
63
72
  key: "disable",
64
73
  value: function disable() {
65
74
  this.touchZoom.disable();
66
75
  this.touchRotate.disable();
67
76
  this.tapDragZoom.disable();
77
+
68
78
  if (!_l7Utils.isMini) {
69
79
  this.el.classList.remove('l7-touch-zoom-rotate');
70
80
  }
71
81
  }
72
-
73
82
  /**
74
83
  * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
75
84
  *
76
85
  * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
77
86
  */
87
+
78
88
  }, {
79
89
  key: "isEnabled",
80
90
  value: function isEnabled() {
81
91
  return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
82
92
  }
83
-
84
93
  /**
85
94
  * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
86
95
  *
87
96
  * @returns {boolean} //eslint-disable-line
88
97
  */
98
+
89
99
  }, {
90
100
  key: "isActive",
91
101
  value: function isActive() {
92
102
  return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
93
103
  }
94
-
95
104
  /**
96
105
  * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
97
106
  * interaction enabled.
@@ -99,13 +108,13 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
99
108
  * @example
100
109
  * map.touchZoomRotate.disableRotation();
101
110
  */
111
+
102
112
  }, {
103
113
  key: "disableRotation",
104
114
  value: function disableRotation() {
105
115
  this.rotationDisabled = true;
106
116
  this.touchRotate.disable();
107
117
  }
108
-
109
118
  /**
110
119
  * Enables the "pinch to rotate" interaction.
111
120
  *
@@ -113,10 +122,12 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
113
122
  * map.touchZoomRotate.enable();
114
123
  * map.touchZoomRotate.enableRotation();
115
124
  */
125
+
116
126
  }, {
117
127
  key: "enableRotation",
118
128
  value: function enableRotation() {
119
129
  this.rotationDisabled = false;
130
+
120
131
  if (this.touchZoom.isEnabled()) {
121
132
  this.touchRotate.enable();
122
133
  }
@@ -124,4 +135,5 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
124
135
  }]);
125
136
  return TouchZoomRotateHandler;
126
137
  }();
138
+
127
139
  exports.default = TouchZoomRotateHandler;
@@ -1,54 +1,70 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = exports.MAX_TOUCH_TIME = exports.MAX_TAP_INTERVAL = exports.MAX_DIST = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _point = _interopRequireDefault(require("../../geo/point"));
15
+
11
16
  var _handler_util = require("../handler_util");
17
+
12
18
  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; } } }; }
19
+
13
20
  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
21
+
22
+ 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; }
23
+
15
24
  function getCentroid(points) {
16
25
  var sum = new _point.default(0, 0);
26
+
17
27
  var _iterator = _createForOfIteratorHelper(points),
18
- _step;
28
+ _step;
29
+
19
30
  try {
20
31
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
21
32
  var point = _step.value;
33
+
22
34
  sum._add(point);
23
- }
24
- // @ts-ignore
35
+ } // @ts-ignore
36
+
25
37
  } catch (err) {
26
38
  _iterator.e(err);
27
39
  } finally {
28
40
  _iterator.f();
29
41
  }
42
+
30
43
  return sum.div(points.length);
31
44
  }
45
+
32
46
  var MAX_TAP_INTERVAL = 500;
33
47
  exports.MAX_TAP_INTERVAL = MAX_TAP_INTERVAL;
34
48
  var MAX_TOUCH_TIME = 500;
35
49
  exports.MAX_TOUCH_TIME = MAX_TOUCH_TIME;
36
50
  var MAX_DIST = 30;
37
51
  exports.MAX_DIST = MAX_DIST;
52
+
38
53
  var SingleTapRecognizer = /*#__PURE__*/function () {
39
54
  function SingleTapRecognizer(options) {
40
55
  (0, _classCallCheck2.default)(this, SingleTapRecognizer);
41
56
  this.reset();
42
57
  this.numTouches = options.numTouches;
43
58
  }
59
+
44
60
  (0, _createClass2.default)(SingleTapRecognizer, [{
45
61
  key: "reset",
46
62
  value: function reset() {
47
63
  // @ts-ignore
48
- delete this.centroid;
49
- // @ts-ignore
50
- delete this.startTime;
51
- // @ts-ignore
64
+ delete this.centroid; // @ts-ignore
65
+
66
+ delete this.startTime; // @ts-ignore
67
+
52
68
  delete this.touches;
53
69
  this.aborted = false;
54
70
  }
@@ -58,12 +74,15 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
58
74
  if (this.centroid || mapTouches.length > this.numTouches) {
59
75
  this.aborted = true;
60
76
  }
77
+
61
78
  if (this.aborted) {
62
79
  return;
63
80
  }
81
+
64
82
  if (this.startTime === undefined) {
65
83
  this.startTime = e.timeStamp;
66
84
  }
85
+
67
86
  if (mapTouches.length === this.numTouches) {
68
87
  this.centroid = getCentroid(points);
69
88
  this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
@@ -75,11 +94,14 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
75
94
  if (this.aborted || !this.centroid) {
76
95
  return;
77
96
  }
97
+
78
98
  var newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
99
+
79
100
  for (var id in this.touches) {
80
101
  if (this.touches[id]) {
81
102
  var prevPos = this.touches[id];
82
103
  var pos = newTouches[id];
104
+
83
105
  if (!pos || pos.dist(prevPos) > MAX_DIST) {
84
106
  this.aborted = true;
85
107
  }
@@ -92,9 +114,11 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
92
114
  if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
93
115
  this.aborted = true;
94
116
  }
117
+
95
118
  if (mapTouches.length === 0) {
96
119
  var centroid = !this.aborted && this.centroid;
97
120
  this.reset();
121
+
98
122
  if (centroid) {
99
123
  return centroid;
100
124
  }
@@ -103,4 +127,5 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
103
127
  }]);
104
128
  return SingleTapRecognizer;
105
129
  }();
130
+
106
131
  exports.default = SingleTapRecognizer;
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _single_tap_recognizer = require("./single_tap_recognizer");
15
+
11
16
  var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
17
+
12
18
  // @ts-ignore
13
19
  var TapDragZoomHandler = /*#__PURE__*/function () {
14
20
  function TapDragZoomHandler() {
@@ -19,15 +25,16 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
19
25
  });
20
26
  this.reset();
21
27
  }
28
+
22
29
  (0, _createClass2.default)(TapDragZoomHandler, [{
23
30
  key: "reset",
24
31
  value: function reset() {
25
- this.active = false;
26
- // @ts-ignore
27
- delete this.swipePoint;
28
- // @ts-ignore
29
- delete this.swipeTouch;
30
- // @ts-ignore
32
+ this.active = false; // @ts-ignore
33
+
34
+ delete this.swipePoint; // @ts-ignore
35
+
36
+ delete this.swipeTouch; // @ts-ignore
37
+
31
38
  delete this.tapTime;
32
39
  this.tap.reset();
33
40
  }
@@ -37,9 +44,11 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
37
44
  if (this.swipePoint) {
38
45
  return;
39
46
  }
47
+
40
48
  if (this.tapTime && e.timeStamp - this.tapTime > _single_tap_recognizer.MAX_TAP_INTERVAL) {
41
49
  this.reset();
42
50
  }
51
+
43
52
  if (!this.tapTime) {
44
53
  this.tap.touchstart(e, points, mapTouches);
45
54
  } else if (mapTouches.length > 0) {
@@ -56,6 +65,7 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
56
65
  if (mapTouches[0].identifier !== this.swipeTouch) {
57
66
  return;
58
67
  }
68
+
59
69
  var newSwipePoint = points[0];
60
70
  var dist = newSwipePoint.y - this.swipePoint.y;
61
71
  this.swipePoint = newSwipePoint;
@@ -71,6 +81,7 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
71
81
  value: function touchend(e, points, mapTouches) {
72
82
  if (!this.tapTime) {
73
83
  var point = this.tap.touchend(e, points, mapTouches);
84
+
74
85
  if (point) {
75
86
  this.tapTime = e.timeStamp;
76
87
  }
@@ -109,4 +120,5 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
109
120
  }]);
110
121
  return TapDragZoomHandler;
111
122
  }();
123
+
112
124
  exports.default = TapDragZoomHandler;
@@ -1,16 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = void 0;
11
+
9
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
10
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
11
16
  var _single_tap_recognizer = _interopRequireWildcard(require("./single_tap_recognizer"));
17
+
12
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
13
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
14
22
  // @ts-ignore
15
23
  var TapRecognizer = /*#__PURE__*/function () {
16
24
  function TapRecognizer(options) {
@@ -19,11 +27,12 @@ var TapRecognizer = /*#__PURE__*/function () {
19
27
  this.numTaps = options.numTaps;
20
28
  this.reset();
21
29
  }
30
+
22
31
  (0, _createClass2.default)(TapRecognizer, [{
23
32
  key: "reset",
24
33
  value: function reset() {
25
- this.lastTime = Infinity;
26
- // @ts-ignore
34
+ this.lastTime = Infinity; // @ts-ignore
35
+
27
36
  delete this.lastTap;
28
37
  this.count = 0;
29
38
  this.singleTap.reset();
@@ -42,15 +51,20 @@ var TapRecognizer = /*#__PURE__*/function () {
42
51
  key: "touchend",
43
52
  value: function touchend(e, points, mapTouches) {
44
53
  var tap = this.singleTap.touchend(e, points, mapTouches);
54
+
45
55
  if (tap) {
46
56
  var soonEnough = e.timeStamp - this.lastTime < _single_tap_recognizer.MAX_TAP_INTERVAL;
57
+
47
58
  var closeEnough = !this.lastTap || this.lastTap.dist(tap) < _single_tap_recognizer.MAX_DIST;
59
+
48
60
  if (!soonEnough || !closeEnough) {
49
61
  this.reset();
50
62
  }
63
+
51
64
  this.count++;
52
65
  this.lastTime = e.timeStamp;
53
66
  this.lastTap = tap;
67
+
54
68
  if (this.count === this.numTaps) {
55
69
  this.reset();
56
70
  return tap;
@@ -60,4 +74,5 @@ var TapRecognizer = /*#__PURE__*/function () {
60
74
  }]);
61
75
  return TapRecognizer;
62
76
  }();
77
+
63
78
  exports.default = TapRecognizer;
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
15
+
11
16
  // @ts-ignore
12
17
  var TapZoomHandler = /*#__PURE__*/function () {
13
18
  function TapZoomHandler() {
@@ -22,6 +27,7 @@ var TapZoomHandler = /*#__PURE__*/function () {
22
27
  });
23
28
  this.reset();
24
29
  }
30
+
25
31
  (0, _createClass2.default)(TapZoomHandler, [{
26
32
  key: "reset",
27
33
  value: function reset() {
@@ -45,8 +51,10 @@ var TapZoomHandler = /*#__PURE__*/function () {
45
51
  key: "touchend",
46
52
  value: function touchend(e, points, mapTouches) {
47
53
  var _this = this;
54
+
48
55
  var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
49
56
  var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
57
+
50
58
  if (zoomInPoint) {
51
59
  this.active = true;
52
60
  e.preventDefault();
@@ -112,4 +120,5 @@ var TapZoomHandler = /*#__PURE__*/function () {
112
120
  }]);
113
121
  return TapZoomHandler;
114
122
  }();
123
+
115
124
  exports.default = TapZoomHandler;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -28,7 +29,11 @@ Object.defineProperty(exports, "TouchZoomHandler", {
28
29
  return _touch_zoom.default;
29
30
  }
30
31
  });
32
+
31
33
  var _touch_pan = _interopRequireDefault(require("./touch_pan"));
34
+
32
35
  var _touch_pitch = _interopRequireDefault(require("./touch_pitch"));
36
+
33
37
  var _touch_rotate = _interopRequireDefault(require("./touch_rotate"));
38
+
34
39
  var _touch_zoom = _interopRequireDefault(require("./touch_zoom"));
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _point = _interopRequireDefault(require("../../geo/point"));
15
+
11
16
  var _handler_util = require("../handler_util");
17
+
12
18
  // @ts-ignore
13
19
  var TouchPanHandler = /*#__PURE__*/function () {
14
20
  function TouchPanHandler(options) {
@@ -17,6 +23,7 @@ var TouchPanHandler = /*#__PURE__*/function () {
17
23
  this.clickTolerance = options.clickTolerance || 1;
18
24
  this.reset();
19
25
  }
26
+
20
27
  (0, _createClass2.default)(TouchPanHandler, [{
21
28
  key: "reset",
22
29
  value: function reset() {
@@ -35,6 +42,7 @@ var TouchPanHandler = /*#__PURE__*/function () {
35
42
  if (!this.active) {
36
43
  return;
37
44
  }
45
+
38
46
  e.preventDefault();
39
47
  return this.calculateTransform(e, points, mapTouches);
40
48
  }
@@ -42,6 +50,7 @@ var TouchPanHandler = /*#__PURE__*/function () {
42
50
  key: "touchend",
43
51
  value: function touchend(e, points, mapTouches) {
44
52
  this.calculateTransform(e, points, mapTouches);
53
+
45
54
  if (this.active && mapTouches.length < this.minTouches) {
46
55
  this.reset();
47
56
  }
@@ -78,33 +87,44 @@ var TouchPanHandler = /*#__PURE__*/function () {
78
87
  if (mapTouches.length > 0) {
79
88
  this.active = true;
80
89
  }
90
+
81
91
  var touches = (0, _handler_util.indexTouches)(mapTouches, points);
82
92
  var touchPointSum = new _point.default(0, 0);
83
93
  var touchDeltaSum = new _point.default(0, 0);
84
94
  var touchDeltaCount = 0;
95
+
85
96
  for (var identifier in touches) {
86
97
  if (touches[identifier]) {
87
98
  var point = touches[identifier];
88
99
  var prevPoint = this.touches[identifier];
100
+
89
101
  if (prevPoint) {
90
102
  touchPointSum._add(point);
103
+
91
104
  touchDeltaSum._add(point.sub(prevPoint));
105
+
92
106
  touchDeltaCount++;
93
107
  touches[identifier] = point;
94
108
  }
95
109
  }
96
110
  }
111
+
97
112
  this.touches = touches;
113
+
98
114
  if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
99
115
  return;
100
- }
101
- // @ts-ignore
116
+ } // @ts-ignore
117
+
118
+
102
119
  var panDelta = touchDeltaSum.div(touchDeltaCount);
120
+
103
121
  this.sum._add(panDelta);
122
+
104
123
  if (this.sum.mag() < this.clickTolerance) {
105
124
  return;
106
- }
107
- // @ts-ignore
125
+ } // @ts-ignore
126
+
127
+
108
128
  var around = touchPointSum.div(touchDeltaCount);
109
129
  return {
110
130
  around: around,
@@ -114,4 +134,5 @@ var TouchPanHandler = /*#__PURE__*/function () {
114
134
  }]);
115
135
  return TouchPanHandler;
116
136
  }();
137
+
117
138
  exports.default = TouchPanHandler;
@@ -1,44 +1,61 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
15
+
11
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
12
18
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
13
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
14
22
  var _two_touch = _interopRequireDefault(require("./two_touch"));
23
+
15
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
- 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; } } // @ts-ignore
25
+
26
+ 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; } }
27
+
17
28
  function isVertical(vector) {
18
29
  return Math.abs(vector.y) > Math.abs(vector.x);
19
30
  }
31
+
20
32
  var ALLOWED_SINGLE_TOUCH_TIME = 100;
33
+
21
34
  var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
22
35
  (0, _inherits2.default)(TouchPitchHandler, _TwoTouchHandler);
36
+
23
37
  var _super = _createSuper(TouchPitchHandler);
38
+
24
39
  function TouchPitchHandler() {
25
40
  (0, _classCallCheck2.default)(this, TouchPitchHandler);
26
41
  return _super.apply(this, arguments);
27
42
  }
43
+
28
44
  (0, _createClass2.default)(TouchPitchHandler, [{
29
45
  key: "reset",
30
46
  value: function reset() {
31
47
  (0, _get2.default)((0, _getPrototypeOf2.default)(TouchPitchHandler.prototype), "reset", this).call(this);
32
- this.valid = undefined;
33
- // @ts-ignore
34
- delete this.firstMove;
35
- // @ts-ignore
48
+ this.valid = undefined; // @ts-ignore
49
+
50
+ delete this.firstMove; // @ts-ignore
51
+
36
52
  delete this.lastPoints;
37
53
  }
38
54
  }, {
39
55
  key: "start",
40
56
  value: function start(points) {
41
57
  this.lastPoints = points;
58
+
42
59
  if (isVertical(points[0].sub(points[1]))) {
43
60
  // fingers are more horizontal than vertical
44
61
  this.valid = false;
@@ -50,9 +67,11 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
50
67
  var vectorA = points[0].sub(this.lastPoints[0]);
51
68
  var vectorB = points[1].sub(this.lastPoints[1]);
52
69
  this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
70
+
53
71
  if (!this.valid) {
54
72
  return;
55
73
  }
74
+
56
75
  this.lastPoints = points;
57
76
  this.active = true;
58
77
  var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
@@ -67,21 +86,22 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
67
86
  if (this.valid !== undefined) {
68
87
  return this.valid;
69
88
  }
89
+
70
90
  var threshold = 2;
71
91
  var movedA = vectorA.mag() >= threshold;
72
- var movedB = vectorB.mag() >= threshold;
92
+ var movedB = vectorB.mag() >= threshold; // neither finger has moved a meaningful amount, wait
73
93
 
74
- // neither finger has moved a meaningful amount, wait
75
94
  if (!movedA && !movedB) {
76
95
  return;
77
- }
78
-
79
- // One finger has moved and the other has not.
96
+ } // One finger has moved and the other has not.
80
97
  // If enough time has passed, decide it is not a pitch.
98
+
99
+
81
100
  if (!movedA || !movedB) {
82
101
  if (this.firstMove === undefined) {
83
102
  this.firstMove = timeStamp;
84
103
  }
104
+
85
105
  if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
86
106
  // still waiting for a movement from the second finger
87
107
  return undefined;
@@ -89,10 +109,12 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
89
109
  return false;
90
110
  }
91
111
  }
112
+
92
113
  var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
93
114
  return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
94
115
  }
95
116
  }]);
96
117
  return TouchPitchHandler;
97
118
  }(_two_touch.default);
119
+
98
120
  exports.default = TouchPitchHandler;