@antv/l7-map 2.18.2 → 2.18.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 (168) hide show
  1. package/es/camera.d.ts +85 -0
  2. package/es/camera.js +718 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +369 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +108 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +73 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +154 -0
  12. package/es/geo/mercator.d.ts +29 -0
  13. package/es/geo/mercator.js +84 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +224 -0
  16. package/es/geo/simple.d.ts +29 -0
  17. package/es/geo/simple.js +87 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +961 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +78 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +180 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +54 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +11 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +64 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +95 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +50 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +26 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +157 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +577 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +9 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +143 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +125 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +118 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +44 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +46 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +46 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +11 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +325 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +67 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +84 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +74 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +115 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +97 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +106 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +54 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +109 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +110 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +93 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +77 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +54 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +125 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +134 -0
  94. package/es/index.d.ts +4 -0
  95. package/es/index.js +4 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +387 -0
  100. package/es/util.d.ts +25 -0
  101. package/es/util.js +88 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +112 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +140 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +47 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +89 -0
  112. package/lib/camera.js +724 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +376 -0
  115. package/lib/geo/edge_insets.js +114 -0
  116. package/lib/geo/lng_lat.js +81 -0
  117. package/lib/geo/lng_lat_bounds.js +161 -0
  118. package/lib/geo/mercator.js +100 -0
  119. package/lib/geo/point.js +231 -0
  120. package/lib/geo/simple.js +104 -0
  121. package/lib/geo/transform.js +971 -0
  122. package/lib/handler/IHandler.js +5 -0
  123. package/lib/handler/blockable_map_event.js +84 -0
  124. package/lib/handler/box_zoom.js +186 -0
  125. package/lib/handler/click_zoom.js +61 -0
  126. package/lib/handler/events/event.js +20 -0
  127. package/lib/handler/events/index.js +27 -0
  128. package/lib/handler/events/map_mouse_event.js +70 -0
  129. package/lib/handler/events/map_touch_event.js +100 -0
  130. package/lib/handler/events/map_wheel_event.js +57 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +162 -0
  133. package/lib/handler/handler_manager.js +584 -0
  134. package/lib/handler/handler_util.js +15 -0
  135. package/lib/handler/keyboard.js +151 -0
  136. package/lib/handler/map_event.js +131 -0
  137. package/lib/handler/mouse/index.js +27 -0
  138. package/lib/handler/mouse/mouse_handler.js +124 -0
  139. package/lib/handler/mouse/mousepan_handler.js +49 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +51 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +51 -0
  142. package/lib/handler/mouse/util.js +22 -0
  143. package/lib/handler/scroll_zoom.js +333 -0
  144. package/lib/handler/shim/dblclick_zoom.js +74 -0
  145. package/lib/handler/shim/drag_pan.js +91 -0
  146. package/lib/handler/shim/drag_rotate.js +81 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +122 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +106 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +112 -0
  150. package/lib/handler/tap/tap_recognizer.js +63 -0
  151. package/lib/handler/tap/tap_zoom.js +115 -0
  152. package/lib/handler/touch/index.js +34 -0
  153. package/lib/handler/touch/touch_pan.js +117 -0
  154. package/lib/handler/touch/touch_pitch.js +98 -0
  155. package/lib/handler/touch/touch_rotate.js +82 -0
  156. package/lib/handler/touch/touch_zoom.js +59 -0
  157. package/lib/handler/touch/two_touch.js +131 -0
  158. package/lib/hash.js +143 -0
  159. package/lib/index.js +49 -0
  160. package/lib/interface.js +5 -0
  161. package/lib/map.js +394 -0
  162. package/lib/util.js +108 -0
  163. package/lib/utils/Aabb.js +119 -0
  164. package/lib/utils/dom.js +147 -0
  165. package/lib/utils/performance.js +70 -0
  166. package/lib/utils/primitives.js +54 -0
  167. package/lib/utils/task_queue.js +97 -0
  168. package/package.json +3 -3
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
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"));
10
+ var _point = _interopRequireDefault(require("../../geo/point"));
11
+ 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
15
+ 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();
29
+ }
30
+ return sum.div(points.length);
31
+ }
32
+ var MAX_TAP_INTERVAL = 500;
33
+ exports.MAX_TAP_INTERVAL = MAX_TAP_INTERVAL;
34
+ var MAX_TOUCH_TIME = 500;
35
+ exports.MAX_TOUCH_TIME = MAX_TOUCH_TIME;
36
+ var MAX_DIST = 30;
37
+ exports.MAX_DIST = MAX_DIST;
38
+ var SingleTapRecognizer = /*#__PURE__*/function () {
39
+ function SingleTapRecognizer(options) {
40
+ (0, _classCallCheck2.default)(this, SingleTapRecognizer);
41
+ this.reset();
42
+ this.numTouches = options.numTouches;
43
+ }
44
+ (0, _createClass2.default)(SingleTapRecognizer, [{
45
+ key: "reset",
46
+ value: function reset() {
47
+ // @ts-ignore
48
+ delete this.centroid;
49
+ // @ts-ignore
50
+ delete this.startTime;
51
+ // @ts-ignore
52
+ delete this.touches;
53
+ this.aborted = false;
54
+ }
55
+ }, {
56
+ key: "touchstart",
57
+ value: function touchstart(e, points, mapTouches) {
58
+ if (this.centroid || mapTouches.length > this.numTouches) {
59
+ this.aborted = true;
60
+ }
61
+ if (this.aborted) {
62
+ return;
63
+ }
64
+ if (this.startTime === undefined) {
65
+ this.startTime = e.timeStamp;
66
+ }
67
+ if (mapTouches.length === this.numTouches) {
68
+ this.centroid = getCentroid(points);
69
+ this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
70
+ }
71
+ }
72
+ }, {
73
+ key: "touchmove",
74
+ value: function touchmove(e, points, mapTouches) {
75
+ if (this.aborted || !this.centroid) {
76
+ return;
77
+ }
78
+ var newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
79
+ for (var id in this.touches) {
80
+ if (this.touches[id]) {
81
+ var prevPos = this.touches[id];
82
+ var pos = newTouches[id];
83
+ if (!pos || pos.dist(prevPos) > MAX_DIST) {
84
+ this.aborted = true;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }, {
90
+ key: "touchend",
91
+ value: function touchend(e, points, mapTouches) {
92
+ if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
93
+ this.aborted = true;
94
+ }
95
+ if (mapTouches.length === 0) {
96
+ var centroid = !this.aborted && this.centroid;
97
+ this.reset();
98
+ if (centroid) {
99
+ return centroid;
100
+ }
101
+ }
102
+ }
103
+ }]);
104
+ return SingleTapRecognizer;
105
+ }();
106
+ exports.default = SingleTapRecognizer;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _single_tap_recognizer = require("./single_tap_recognizer");
11
+ var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
12
+ // @ts-ignore
13
+ var TapDragZoomHandler = /*#__PURE__*/function () {
14
+ function TapDragZoomHandler() {
15
+ (0, _classCallCheck2.default)(this, TapDragZoomHandler);
16
+ this.tap = new _tap_recognizer.default({
17
+ numTouches: 1,
18
+ numTaps: 1
19
+ });
20
+ this.reset();
21
+ }
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();
33
+ }
34
+ }, {
35
+ key: "touchstart",
36
+ value: function touchstart(e, points, mapTouches) {
37
+ if (this.swipePoint) {
38
+ return;
39
+ }
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
+ }
49
+ }
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
+ }
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
+ }
81
+ }
82
+ }
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
+ }();
112
+ exports.default = TapDragZoomHandler;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _single_tap_recognizer = _interopRequireWildcard(require("./single_tap_recognizer"));
12
+ 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); }
13
+ 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; }
14
+ // @ts-ignore
15
+ var TapRecognizer = /*#__PURE__*/function () {
16
+ function TapRecognizer(options) {
17
+ (0, _classCallCheck2.default)(this, TapRecognizer);
18
+ this.singleTap = new _single_tap_recognizer.default(options);
19
+ this.numTaps = options.numTaps;
20
+ this.reset();
21
+ }
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
+ }
58
+ }
59
+ }
60
+ }]);
61
+ return TapRecognizer;
62
+ }();
63
+ exports.default = TapRecognizer;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
11
+ // @ts-ignore
12
+ var TapZoomHandler = /*#__PURE__*/function () {
13
+ function TapZoomHandler() {
14
+ (0, _classCallCheck2.default)(this, TapZoomHandler);
15
+ this.zoomIn = new _tap_recognizer.default({
16
+ numTouches: 1,
17
+ numTaps: 2
18
+ });
19
+ this.zoomOut = new _tap_recognizer.default({
20
+ numTouches: 2,
21
+ numTaps: 1
22
+ });
23
+ this.reset();
24
+ }
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;
111
+ }
112
+ }]);
113
+ return TapZoomHandler;
114
+ }();
115
+ exports.default = TapZoomHandler;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "TouchPanHandler", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _touch_pan.default;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "TouchPitchHandler", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _touch_pitch.default;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "TouchRotateHandler", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _touch_rotate.default;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "TouchZoomHandler", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _touch_zoom.default;
29
+ }
30
+ });
31
+ var _touch_pan = _interopRequireDefault(require("./touch_pan"));
32
+ var _touch_pitch = _interopRequireDefault(require("./touch_pitch"));
33
+ var _touch_rotate = _interopRequireDefault(require("./touch_rotate"));
34
+ var _touch_zoom = _interopRequireDefault(require("./touch_zoom"));
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _point = _interopRequireDefault(require("../../geo/point"));
11
+ var _handler_util = require("../handler_util");
12
+ // @ts-ignore
13
+ var TouchPanHandler = /*#__PURE__*/function () {
14
+ function TouchPanHandler(options) {
15
+ (0, _classCallCheck2.default)(this, TouchPanHandler);
16
+ this.minTouches = 1;
17
+ this.clickTolerance = options.clickTolerance || 1;
18
+ this.reset();
19
+ }
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;
58
+ }
59
+ }, {
60
+ key: "disable",
61
+ value: function disable() {
62
+ this.enabled = false;
63
+ this.reset();
64
+ }
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;
74
+ }
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
+ }
95
+ }
96
+ }
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
+ }
114
+ }]);
115
+ return TouchPanHandler;
116
+ }();
117
+ exports.default = TouchPanHandler;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _two_touch = _interopRequireDefault(require("./two_touch"));
15
+ 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
17
+ function isVertical(vector) {
18
+ return Math.abs(vector.y) > Math.abs(vector.x);
19
+ }
20
+ var ALLOWED_SINGLE_TOUCH_TIME = 100;
21
+ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
22
+ (0, _inherits2.default)(TouchPitchHandler, _TwoTouchHandler);
23
+ var _super = _createSuper(TouchPitchHandler);
24
+ function TouchPitchHandler() {
25
+ (0, _classCallCheck2.default)(this, TouchPitchHandler);
26
+ return _super.apply(this, arguments);
27
+ }
28
+ (0, _createClass2.default)(TouchPitchHandler, [{
29
+ key: "reset",
30
+ value: function reset() {
31
+ (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
36
+ delete this.lastPoints;
37
+ }
38
+ }, {
39
+ key: "start",
40
+ value: function start(points) {
41
+ this.lastPoints = points;
42
+ if (isVertical(points[0].sub(points[1]))) {
43
+ // fingers are more horizontal than vertical
44
+ this.valid = false;
45
+ }
46
+ }
47
+ }, {
48
+ key: "move",
49
+ value: function move(points, center, e) {
50
+ var vectorA = points[0].sub(this.lastPoints[0]);
51
+ var vectorB = points[1].sub(this.lastPoints[1]);
52
+ this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
53
+ if (!this.valid) {
54
+ return;
55
+ }
56
+ this.lastPoints = points;
57
+ this.active = true;
58
+ var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
59
+ var degreesPerPixelMoved = -0.5;
60
+ return {
61
+ pitchDelta: yDeltaAverage * degreesPerPixelMoved
62
+ };
63
+ }
64
+ }, {
65
+ key: "gestureBeginsVertically",
66
+ value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
67
+ if (this.valid !== undefined) {
68
+ return this.valid;
69
+ }
70
+ var threshold = 2;
71
+ var movedA = vectorA.mag() >= threshold;
72
+ var movedB = vectorB.mag() >= threshold;
73
+
74
+ // neither finger has moved a meaningful amount, wait
75
+ if (!movedA && !movedB) {
76
+ return;
77
+ }
78
+
79
+ // One finger has moved and the other has not.
80
+ // If enough time has passed, decide it is not a pitch.
81
+ if (!movedA || !movedB) {
82
+ if (this.firstMove === undefined) {
83
+ this.firstMove = timeStamp;
84
+ }
85
+ if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
86
+ // still waiting for a movement from the second finger
87
+ return undefined;
88
+ } else {
89
+ return false;
90
+ }
91
+ }
92
+ var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
93
+ return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
94
+ }
95
+ }]);
96
+ return TouchPitchHandler;
97
+ }(_two_touch.default);
98
+ exports.default = TouchPitchHandler;