@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,109 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ // @ts-ignore
4
+
5
+ import TapRecognizer from "./tap_recognizer";
6
+ var TapZoomHandler = /*#__PURE__*/function () {
7
+ function TapZoomHandler() {
8
+ _classCallCheck(this, TapZoomHandler);
9
+ this.zoomIn = new TapRecognizer({
10
+ numTouches: 1,
11
+ numTaps: 2
12
+ });
13
+ this.zoomOut = new TapRecognizer({
14
+ numTouches: 2,
15
+ numTaps: 1
16
+ });
17
+ this.reset();
18
+ }
19
+ _createClass(TapZoomHandler, [{
20
+ key: "reset",
21
+ value: function reset() {
22
+ this.active = false;
23
+ this.zoomIn.reset();
24
+ this.zoomOut.reset();
25
+ }
26
+ }, {
27
+ key: "touchstart",
28
+ value: function touchstart(e, points, mapTouches) {
29
+ this.zoomIn.touchstart(e, points, mapTouches);
30
+ this.zoomOut.touchstart(e, points, mapTouches);
31
+ }
32
+ }, {
33
+ key: "touchmove",
34
+ value: function touchmove(e, points, mapTouches) {
35
+ this.zoomIn.touchmove(e, points, mapTouches);
36
+ this.zoomOut.touchmove(e, points, mapTouches);
37
+ }
38
+ }, {
39
+ key: "touchend",
40
+ value: function touchend(e, points, mapTouches) {
41
+ var _this = this;
42
+ var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
43
+ var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
44
+ if (zoomInPoint) {
45
+ this.active = true;
46
+ e.preventDefault();
47
+ setTimeout(function () {
48
+ return _this.reset();
49
+ }, 0);
50
+ return {
51
+ cameraAnimation: function cameraAnimation(map) {
52
+ return map.easeTo({
53
+ duration: 300,
54
+ zoom: map.getZoom() + 1,
55
+ around: map.unproject(zoomInPoint)
56
+ }, {
57
+ originalEvent: e
58
+ });
59
+ }
60
+ };
61
+ } else if (zoomOutPoint) {
62
+ this.active = true;
63
+ e.preventDefault();
64
+ setTimeout(function () {
65
+ return _this.reset();
66
+ }, 0);
67
+ return {
68
+ cameraAnimation: function cameraAnimation(map) {
69
+ return map.easeTo({
70
+ duration: 300,
71
+ zoom: map.getZoom() - 1,
72
+ around: map.unproject(zoomOutPoint)
73
+ }, {
74
+ originalEvent: e
75
+ });
76
+ }
77
+ };
78
+ }
79
+ }
80
+ }, {
81
+ key: "touchcancel",
82
+ value: function touchcancel() {
83
+ this.reset();
84
+ }
85
+ }, {
86
+ key: "enable",
87
+ value: function enable() {
88
+ this.enabled = true;
89
+ }
90
+ }, {
91
+ key: "disable",
92
+ value: function disable() {
93
+ this.enabled = false;
94
+ this.reset();
95
+ }
96
+ }, {
97
+ key: "isEnabled",
98
+ value: function isEnabled() {
99
+ return this.enabled;
100
+ }
101
+ }, {
102
+ key: "isActive",
103
+ value: function isActive() {
104
+ return this.active;
105
+ }
106
+ }]);
107
+ return TapZoomHandler;
108
+ }();
109
+ export { TapZoomHandler as default };
@@ -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, };
@@ -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 };
@@ -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
+ }
@@ -0,0 +1,110 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ // @ts-ignore
4
+ import Point from "../../geo/point";
5
+ import { indexTouches } from "../handler_util";
6
+ var TouchPanHandler = /*#__PURE__*/function () {
7
+ function TouchPanHandler(options) {
8
+ _classCallCheck(this, TouchPanHandler);
9
+ this.minTouches = 1;
10
+ this.clickTolerance = options.clickTolerance || 1;
11
+ this.reset();
12
+ }
13
+ _createClass(TouchPanHandler, [{
14
+ key: "reset",
15
+ value: function reset() {
16
+ this.active = false;
17
+ this.touches = {};
18
+ this.sum = new Point(0, 0);
19
+ }
20
+ }, {
21
+ key: "touchstart",
22
+ value: function touchstart(e, points, mapTouches) {
23
+ return this.calculateTransform(e, points, mapTouches);
24
+ }
25
+ }, {
26
+ key: "touchmove",
27
+ value: function touchmove(e, points, mapTouches) {
28
+ if (!this.active) {
29
+ return;
30
+ }
31
+ e.preventDefault();
32
+ return this.calculateTransform(e, points, mapTouches);
33
+ }
34
+ }, {
35
+ key: "touchend",
36
+ value: function touchend(e, points, mapTouches) {
37
+ this.calculateTransform(e, points, mapTouches);
38
+ if (this.active && mapTouches.length < this.minTouches) {
39
+ this.reset();
40
+ }
41
+ }
42
+ }, {
43
+ key: "touchcancel",
44
+ value: function touchcancel() {
45
+ this.reset();
46
+ }
47
+ }, {
48
+ key: "enable",
49
+ value: function enable() {
50
+ this.enabled = true;
51
+ }
52
+ }, {
53
+ key: "disable",
54
+ value: function disable() {
55
+ this.enabled = false;
56
+ this.reset();
57
+ }
58
+ }, {
59
+ key: "isEnabled",
60
+ value: function isEnabled() {
61
+ return this.enabled;
62
+ }
63
+ }, {
64
+ key: "isActive",
65
+ value: function isActive() {
66
+ return this.active;
67
+ }
68
+ }, {
69
+ key: "calculateTransform",
70
+ value: function calculateTransform(e, points, mapTouches) {
71
+ if (mapTouches.length > 0) {
72
+ this.active = true;
73
+ }
74
+ var touches = indexTouches(mapTouches, points);
75
+ var touchPointSum = new Point(0, 0);
76
+ var touchDeltaSum = new Point(0, 0);
77
+ var touchDeltaCount = 0;
78
+ for (var identifier in touches) {
79
+ if (touches[identifier]) {
80
+ var point = touches[identifier];
81
+ var prevPoint = this.touches[identifier];
82
+ if (prevPoint) {
83
+ touchPointSum._add(point);
84
+ touchDeltaSum._add(point.sub(prevPoint));
85
+ touchDeltaCount++;
86
+ touches[identifier] = point;
87
+ }
88
+ }
89
+ }
90
+ this.touches = touches;
91
+ if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
92
+ return;
93
+ }
94
+ // @ts-ignore
95
+ var panDelta = touchDeltaSum.div(touchDeltaCount);
96
+ this.sum._add(panDelta);
97
+ if (this.sum.mag() < this.clickTolerance) {
98
+ return;
99
+ }
100
+ // @ts-ignore
101
+ var around = touchPointSum.div(touchDeltaCount);
102
+ return {
103
+ around: around,
104
+ panDelta: panDelta
105
+ };
106
+ }
107
+ }]);
108
+ return TouchPanHandler;
109
+ }();
110
+ export { TouchPanHandler as default };
@@ -0,0 +1,13 @@
1
+ import 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
+ }
@@ -0,0 +1,93 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _get from "@babel/runtime/helpers/esm/get";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ 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; } }
9
+ // @ts-ignore
10
+
11
+ import TwoTouchHandler from "./two_touch";
12
+ function isVertical(vector) {
13
+ return Math.abs(vector.y) > Math.abs(vector.x);
14
+ }
15
+ var ALLOWED_SINGLE_TOUCH_TIME = 100;
16
+ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
17
+ _inherits(TouchPitchHandler, _TwoTouchHandler);
18
+ var _super = _createSuper(TouchPitchHandler);
19
+ function TouchPitchHandler() {
20
+ _classCallCheck(this, TouchPitchHandler);
21
+ return _super.apply(this, arguments);
22
+ }
23
+ _createClass(TouchPitchHandler, [{
24
+ key: "reset",
25
+ value: function reset() {
26
+ _get(_getPrototypeOf(TouchPitchHandler.prototype), "reset", this).call(this);
27
+ this.valid = undefined;
28
+ // @ts-ignore
29
+ delete this.firstMove;
30
+ // @ts-ignore
31
+ delete this.lastPoints;
32
+ }
33
+ }, {
34
+ key: "start",
35
+ value: function start(points) {
36
+ this.lastPoints = points;
37
+ if (isVertical(points[0].sub(points[1]))) {
38
+ // fingers are more horizontal than vertical
39
+ this.valid = false;
40
+ }
41
+ }
42
+ }, {
43
+ key: "move",
44
+ value: function move(points, center, e) {
45
+ var vectorA = points[0].sub(this.lastPoints[0]);
46
+ var vectorB = points[1].sub(this.lastPoints[1]);
47
+ this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
48
+ if (!this.valid) {
49
+ return;
50
+ }
51
+ this.lastPoints = points;
52
+ this.active = true;
53
+ var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
54
+ var degreesPerPixelMoved = -0.5;
55
+ return {
56
+ pitchDelta: yDeltaAverage * degreesPerPixelMoved
57
+ };
58
+ }
59
+ }, {
60
+ key: "gestureBeginsVertically",
61
+ value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
62
+ if (this.valid !== undefined) {
63
+ return this.valid;
64
+ }
65
+ var threshold = 2;
66
+ var movedA = vectorA.mag() >= threshold;
67
+ var movedB = vectorB.mag() >= threshold;
68
+
69
+ // neither finger has moved a meaningful amount, wait
70
+ if (!movedA && !movedB) {
71
+ return;
72
+ }
73
+
74
+ // One finger has moved and the other has not.
75
+ // If enough time has passed, decide it is not a pitch.
76
+ if (!movedA || !movedB) {
77
+ if (this.firstMove === undefined) {
78
+ this.firstMove = timeStamp;
79
+ }
80
+ if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
81
+ // still waiting for a movement from the second finger
82
+ return undefined;
83
+ } else {
84
+ return false;
85
+ }
86
+ }
87
+ var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
88
+ return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
89
+ }
90
+ }]);
91
+ return TouchPitchHandler;
92
+ }(TwoTouchHandler);
93
+ export { TouchPitchHandler as default };
@@ -0,0 +1,12 @@
1
+ import Point from '../../geo/point';
2
+ import TwoTouchHandler from './two_touch';
3
+ export default class TouchRotateHandler extends TwoTouchHandler {
4
+ private minDiameter;
5
+ reset(): void;
6
+ start(points: [Point, Point]): void;
7
+ move(points: [Point, Point], pinchAround: Point): {
8
+ bearingDelta: number;
9
+ pinchAround: Point;
10
+ } | undefined;
11
+ private isBelowThreshold;
12
+ }
@@ -0,0 +1,77 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _get from "@babel/runtime/helpers/esm/get";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ 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; } }
9
+ // @ts-ignore
10
+
11
+ import TwoTouchHandler from "./two_touch";
12
+ var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
13
+
14
+ function getBearingDelta(a, b) {
15
+ return a.angleWith(b) * 180 / Math.PI;
16
+ }
17
+ var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
18
+ _inherits(TouchRotateHandler, _TwoTouchHandler);
19
+ var _super = _createSuper(TouchRotateHandler);
20
+ function TouchRotateHandler() {
21
+ _classCallCheck(this, TouchRotateHandler);
22
+ return _super.apply(this, arguments);
23
+ }
24
+ _createClass(TouchRotateHandler, [{
25
+ key: "reset",
26
+ value: function reset() {
27
+ _get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this);
28
+ // @ts-ignore
29
+ delete this.minDiameter;
30
+ // @ts-ignore
31
+ delete this.startVector;
32
+ // @ts-ignore
33
+ delete this.vector;
34
+ }
35
+ }, {
36
+ key: "start",
37
+ value: function start(points) {
38
+ this.startVector = this.vector = points[0].sub(points[1]);
39
+ this.minDiameter = points[0].dist(points[1]);
40
+ }
41
+ }, {
42
+ key: "move",
43
+ value: function move(points, pinchAround) {
44
+ var lastVector = this.vector;
45
+ this.vector = points[0].sub(points[1]);
46
+ if (!this.active && this.isBelowThreshold(this.vector)) {
47
+ return;
48
+ }
49
+ this.active = true;
50
+ return {
51
+ bearingDelta: getBearingDelta(this.vector, lastVector),
52
+ pinchAround: pinchAround
53
+ };
54
+ }
55
+ }, {
56
+ key: "isBelowThreshold",
57
+ value: function isBelowThreshold(vector) {
58
+ /*
59
+ * The threshold before a rotation actually happens is configured in
60
+ * pixels alongth circumference of the circle formed by the two fingers.
61
+ * This makes the threshold in degrees larger when the fingers are close
62
+ * together and smaller when the fingers are far apart.
63
+ *
64
+ * Use the smallest diameter from the whole gesture to reduce sensitivity
65
+ * when pinching in and out.
66
+ */
67
+
68
+ this.minDiameter = Math.min(this.minDiameter, vector.mag());
69
+ var circumference = Math.PI * this.minDiameter;
70
+ var threshold = ROTATION_THRESHOLD / circumference * 360;
71
+ var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
72
+ return Math.abs(bearingDeltaSinceStart) < threshold;
73
+ }
74
+ }]);
75
+ return TouchRotateHandler;
76
+ }(TwoTouchHandler);
77
+ export { TouchRotateHandler as default };
@@ -0,0 +1,12 @@
1
+ import Point from '../../geo/point';
2
+ import TwoTouchHandler from './two_touch';
3
+ export default class TouchZoomHandler extends TwoTouchHandler {
4
+ private distance;
5
+ private startDistance;
6
+ reset(): void;
7
+ start(points: [Point, Point]): void;
8
+ move(points: [Point, Point], pinchAround: Point): {
9
+ zoomDelta: number;
10
+ pinchAround: Point;
11
+ } | undefined;
12
+ }
@@ -0,0 +1,54 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _get from "@babel/runtime/helpers/esm/get";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ 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; } }
9
+ // @ts-ignore
10
+
11
+ import TwoTouchHandler from "./two_touch";
12
+ var ZOOM_THRESHOLD = 0.1;
13
+ function getZoomDelta(distance, lastDistance) {
14
+ return Math.log(distance / lastDistance) / Math.LN2;
15
+ }
16
+ var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
17
+ _inherits(TouchZoomHandler, _TwoTouchHandler);
18
+ var _super = _createSuper(TouchZoomHandler);
19
+ function TouchZoomHandler() {
20
+ _classCallCheck(this, TouchZoomHandler);
21
+ return _super.apply(this, arguments);
22
+ }
23
+ _createClass(TouchZoomHandler, [{
24
+ key: "reset",
25
+ value: function reset() {
26
+ _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this);
27
+ // @ts-ignore
28
+ delete this.distance;
29
+ // @ts-ignore
30
+ delete this.startDistance;
31
+ }
32
+ }, {
33
+ key: "start",
34
+ value: function start(points) {
35
+ this.startDistance = this.distance = points[0].dist(points[1]);
36
+ }
37
+ }, {
38
+ key: "move",
39
+ value: function move(points, pinchAround) {
40
+ var lastDistance = this.distance;
41
+ this.distance = points[0].dist(points[1]);
42
+ if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
43
+ return;
44
+ }
45
+ this.active = true;
46
+ return {
47
+ zoomDelta: getZoomDelta(this.distance, lastDistance),
48
+ pinchAround: pinchAround
49
+ };
50
+ }
51
+ }]);
52
+ return TouchZoomHandler;
53
+ }(TwoTouchHandler);
54
+ export { TouchZoomHandler as default };
@@ -0,0 +1,23 @@
1
+ import Point from '../../geo/point';
2
+ export default class TwoTouchHandler {
3
+ protected enabled: boolean;
4
+ protected active: boolean;
5
+ protected firstTwoTouches: [number, number];
6
+ protected vector: Point;
7
+ protected startVector: Point;
8
+ protected aroundCenter: boolean;
9
+ constructor();
10
+ reset(): void;
11
+ start(points: [Point, Point]): void;
12
+ move(points: [Point, Point], pinchAround: Point | null, e: TouchEvent): void;
13
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
14
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
15
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
16
+ touchcancel(): void;
17
+ enable(options?: {
18
+ around?: 'center';
19
+ }): void;
20
+ disable(): void;
21
+ isEnabled(): boolean;
22
+ isActive(): boolean;
23
+ }
@@ -0,0 +1,125 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ // @ts-ignore
5
+
6
+ import DOM from "../../utils/dom";
7
+ var TwoTouchHandler = /*#__PURE__*/function () {
8
+ function TwoTouchHandler() {
9
+ _classCallCheck(this, TwoTouchHandler);
10
+ this.reset();
11
+ }
12
+ _createClass(TwoTouchHandler, [{
13
+ key: "reset",
14
+ value: function reset() {
15
+ this.active = false;
16
+ // @ts-ignore
17
+ delete this.firstTwoTouches;
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ }, {
21
+ key: "start",
22
+ value: function start(points) {
23
+ return;
24
+ } // eslint-disable-line
25
+ }, {
26
+ key: "move",
27
+ value: function move(
28
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+ points,
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ pinchAround,
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ e) {
34
+ return;
35
+ } // eslint-disable-line
36
+ }, {
37
+ key: "touchstart",
38
+ value: function touchstart(e, points, mapTouches) {
39
+ // console.log(e.target, e.targetTouches.length ? e.targetTouches[0].target : null);
40
+ // log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);
41
+ if (this.firstTwoTouches || mapTouches.length < 2) {
42
+ return;
43
+ }
44
+ this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
45
+
46
+ // implemented by child classes
47
+ this.start([points[0], points[1]]);
48
+ }
49
+ }, {
50
+ key: "touchmove",
51
+ value: function touchmove(e, points, mapTouches) {
52
+ if (!this.firstTwoTouches) {
53
+ return;
54
+ }
55
+ e.preventDefault();
56
+ var _this$firstTwoTouches = _slicedToArray(this.firstTwoTouches, 2),
57
+ idA = _this$firstTwoTouches[0],
58
+ idB = _this$firstTwoTouches[1];
59
+ var a = getTouchById(mapTouches, points, idA);
60
+ var b = getTouchById(mapTouches, points, idB);
61
+ if (!a || !b) {
62
+ return;
63
+ }
64
+ var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
65
+
66
+ // implemented by child classes
67
+ return this.move([a, b], pinchAround, e);
68
+ }
69
+ }, {
70
+ key: "touchend",
71
+ value: function touchend(e, points, mapTouches) {
72
+ if (!this.firstTwoTouches) {
73
+ return;
74
+ }
75
+ var _this$firstTwoTouches2 = _slicedToArray(this.firstTwoTouches, 2),
76
+ idA = _this$firstTwoTouches2[0],
77
+ idB = _this$firstTwoTouches2[1];
78
+ var a = getTouchById(mapTouches, points, idA);
79
+ var b = getTouchById(mapTouches, points, idB);
80
+ if (a && b) {
81
+ return;
82
+ }
83
+ if (this.active) {
84
+ DOM.suppressClick();
85
+ }
86
+ this.reset();
87
+ }
88
+ }, {
89
+ key: "touchcancel",
90
+ value: function touchcancel() {
91
+ this.reset();
92
+ }
93
+ }, {
94
+ key: "enable",
95
+ value: function enable(options) {
96
+ this.enabled = true;
97
+ this.aroundCenter = !!options && options.around === 'center';
98
+ }
99
+ }, {
100
+ key: "disable",
101
+ value: function disable() {
102
+ this.enabled = false;
103
+ this.reset();
104
+ }
105
+ }, {
106
+ key: "isEnabled",
107
+ value: function isEnabled() {
108
+ return this.enabled;
109
+ }
110
+ }, {
111
+ key: "isActive",
112
+ value: function isActive() {
113
+ return this.active;
114
+ }
115
+ }]);
116
+ return TwoTouchHandler;
117
+ }();
118
+ export { TwoTouchHandler as default };
119
+ function getTouchById(mapTouches, points, identifier) {
120
+ for (var i = 0; i < mapTouches.length; i++) {
121
+ if (mapTouches[i].identifier === identifier) {
122
+ return points[i];
123
+ }
124
+ }
125
+ }