@antv/l7-map 2.9.37-alpha.2 → 2.9.37-alpha.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 +84 -0
  2. package/es/camera.js +767 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +422 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +118 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +81 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +167 -0
  12. package/es/geo/mercator.d.ts +28 -0
  13. package/es/geo/mercator.js +91 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +231 -0
  16. package/es/geo/simple.d.ts +29 -0
  17. package/es/geo/simple.js +92 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +971 -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 +83 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +200 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +59 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +12 -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 +75 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +105 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +61 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +39 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +184 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +684 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +10 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +162 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +131 -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 +131 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +54 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +56 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +56 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +12 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +353 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +72 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +96 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +80 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +130 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +120 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +114 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +62 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +115 -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 +128 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +110 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +88 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +67 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +138 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +156 -0
  94. package/es/index.d.ts +3 -0
  95. package/es/index.js +3 -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 +464 -0
  100. package/es/util.d.ts +18 -0
  101. package/es/util.js +84 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +133 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +218 -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 +45 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +106 -0
  112. package/lib/camera.js +793 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +445 -0
  115. package/lib/geo/edge_insets.js +129 -0
  116. package/lib/geo/lng_lat.js +94 -0
  117. package/lib/geo/lng_lat_bounds.js +177 -0
  118. package/lib/geo/mercator.js +120 -0
  119. package/lib/geo/point.js +239 -0
  120. package/lib/geo/simple.js +123 -0
  121. package/lib/geo/transform.js +1013 -0
  122. package/lib/handler/IHandler.js +5 -0
  123. package/lib/handler/blockable_map_event.js +92 -0
  124. package/lib/handler/box_zoom.js +217 -0
  125. package/lib/handler/click_zoom.js +67 -0
  126. package/lib/handler/events/event.js +23 -0
  127. package/lib/handler/events/index.js +31 -0
  128. package/lib/handler/events/map_mouse_event.js +87 -0
  129. package/lib/handler/events/map_touch_event.js +119 -0
  130. package/lib/handler/events/map_wheel_event.js +72 -0
  131. package/lib/handler/events/render_event.js +52 -0
  132. package/lib/handler/handler_inertia.js +193 -0
  133. package/lib/handler/handler_manager.js +714 -0
  134. package/lib/handler/handler_util.js +17 -0
  135. package/lib/handler/keyboard.js +172 -0
  136. package/lib/handler/map_event.js +140 -0
  137. package/lib/handler/mouse/index.js +31 -0
  138. package/lib/handler/mouse/mouse_handler.js +141 -0
  139. package/lib/handler/mouse/mousepan_handler.js +66 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +67 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +67 -0
  142. package/lib/handler/mouse/util.js +26 -0
  143. package/lib/handler/scroll_zoom.js +367 -0
  144. package/lib/handler/shim/dblclick_zoom.js +80 -0
  145. package/lib/handler/shim/drag_pan.js +105 -0
  146. package/lib/handler/shim/drag_rotate.js +88 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +139 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +131 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +124 -0
  150. package/lib/handler/tap/tap_recognizer.js +78 -0
  151. package/lib/handler/tap/tap_zoom.js +124 -0
  152. package/lib/handler/touch/index.js +39 -0
  153. package/lib/handler/touch/touch_pan.js +138 -0
  154. package/lib/handler/touch/touch_pitch.js +120 -0
  155. package/lib/handler/touch/touch_rotate.js +99 -0
  156. package/lib/handler/touch/touch_zoom.js +78 -0
  157. package/lib/handler/touch/two_touch.js +148 -0
  158. package/lib/hash.js +169 -0
  159. package/lib/index.js +44 -0
  160. package/lib/interface.js +5 -0
  161. package/lib/map.js +489 -0
  162. package/lib/util.js +116 -0
  163. package/lib/utils/Aabb.js +143 -0
  164. package/lib/utils/dom.js +233 -0
  165. package/lib/utils/performance.js +72 -0
  166. package/lib/utils/primitives.js +57 -0
  167. package/lib/utils/task_queue.js +115 -0
  168. package/package.json +3 -3
@@ -0,0 +1,17 @@
1
+ import Point from '../../geo/point';
2
+ import SingleTapRecognizer from './single_tap_recognizer';
3
+ export default class TapRecognizer {
4
+ singleTap: SingleTapRecognizer;
5
+ numTaps: number;
6
+ lastTime: number;
7
+ lastTap: Point;
8
+ count: number;
9
+ constructor(options: {
10
+ numTaps: number;
11
+ numTouches: number;
12
+ });
13
+ reset(): void;
14
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
15
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
16
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
17
+ }
@@ -0,0 +1,62 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
5
+
6
+ var TapRecognizer = /*#__PURE__*/function () {
7
+ function TapRecognizer(options) {
8
+ _classCallCheck(this, TapRecognizer);
9
+
10
+ this.singleTap = new SingleTapRecognizer(options);
11
+ this.numTaps = options.numTaps;
12
+ this.reset();
13
+ }
14
+
15
+ _createClass(TapRecognizer, [{
16
+ key: "reset",
17
+ value: function reset() {
18
+ this.lastTime = Infinity; //@ts-ignore
19
+
20
+ delete this.lastTap;
21
+ this.count = 0;
22
+ this.singleTap.reset();
23
+ }
24
+ }, {
25
+ key: "touchstart",
26
+ value: function touchstart(e, points, mapTouches) {
27
+ this.singleTap.touchstart(e, points, mapTouches);
28
+ }
29
+ }, {
30
+ key: "touchmove",
31
+ value: function touchmove(e, points, mapTouches) {
32
+ this.singleTap.touchmove(e, points, mapTouches);
33
+ }
34
+ }, {
35
+ key: "touchend",
36
+ value: function touchend(e, points, mapTouches) {
37
+ var tap = this.singleTap.touchend(e, points, mapTouches);
38
+
39
+ if (tap) {
40
+ var soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
41
+ var closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
42
+
43
+ if (!soonEnough || !closeEnough) {
44
+ this.reset();
45
+ }
46
+
47
+ this.count++;
48
+ this.lastTime = e.timeStamp;
49
+ this.lastTap = tap;
50
+
51
+ if (this.count === this.numTaps) {
52
+ this.reset();
53
+ return tap;
54
+ }
55
+ }
56
+ }
57
+ }]);
58
+
59
+ return TapRecognizer;
60
+ }();
61
+
62
+ export { TapRecognizer as default };
@@ -0,0 +1,22 @@
1
+ import { EarthMap } from '../../earthmap';
2
+ import Point from '../../geo/point';
3
+ import { Map } from '../../map';
4
+ import TapRecognizer from './tap_recognizer';
5
+ export default class TapZoomHandler {
6
+ enabled: boolean;
7
+ active: boolean;
8
+ zoomIn: TapRecognizer;
9
+ zoomOut: TapRecognizer;
10
+ constructor();
11
+ reset(): void;
12
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
13
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
14
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
15
+ cameraAnimation: (map: Map | EarthMap) => Map | EarthMap;
16
+ } | undefined;
17
+ touchcancel(): void;
18
+ enable(): void;
19
+ disable(): void;
20
+ isEnabled(): boolean;
21
+ isActive(): boolean;
22
+ }
@@ -0,0 +1,115 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import TapRecognizer from "./tap_recognizer";
5
+
6
+ var TapZoomHandler = /*#__PURE__*/function () {
7
+ function TapZoomHandler() {
8
+ _classCallCheck(this, TapZoomHandler);
9
+
10
+ this.zoomIn = new TapRecognizer({
11
+ numTouches: 1,
12
+ numTaps: 2
13
+ });
14
+ this.zoomOut = new TapRecognizer({
15
+ numTouches: 2,
16
+ numTaps: 1
17
+ });
18
+ this.reset();
19
+ }
20
+
21
+ _createClass(TapZoomHandler, [{
22
+ key: "reset",
23
+ value: function reset() {
24
+ this.active = false;
25
+ this.zoomIn.reset();
26
+ this.zoomOut.reset();
27
+ }
28
+ }, {
29
+ key: "touchstart",
30
+ value: function touchstart(e, points, mapTouches) {
31
+ this.zoomIn.touchstart(e, points, mapTouches);
32
+ this.zoomOut.touchstart(e, points, mapTouches);
33
+ }
34
+ }, {
35
+ key: "touchmove",
36
+ value: function touchmove(e, points, mapTouches) {
37
+ this.zoomIn.touchmove(e, points, mapTouches);
38
+ this.zoomOut.touchmove(e, points, mapTouches);
39
+ }
40
+ }, {
41
+ key: "touchend",
42
+ value: function touchend(e, points, mapTouches) {
43
+ var _this = this;
44
+
45
+ var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
46
+ var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
47
+
48
+ if (zoomInPoint) {
49
+ this.active = true;
50
+ e.preventDefault();
51
+ setTimeout(function () {
52
+ return _this.reset();
53
+ }, 0);
54
+ return {
55
+ cameraAnimation: function cameraAnimation(map) {
56
+ return map.easeTo({
57
+ duration: 300,
58
+ zoom: map.getZoom() + 1,
59
+ around: map.unproject(zoomInPoint)
60
+ }, {
61
+ originalEvent: e
62
+ });
63
+ }
64
+ };
65
+ } else if (zoomOutPoint) {
66
+ this.active = true;
67
+ e.preventDefault();
68
+ setTimeout(function () {
69
+ return _this.reset();
70
+ }, 0);
71
+ return {
72
+ cameraAnimation: function cameraAnimation(map) {
73
+ return map.easeTo({
74
+ duration: 300,
75
+ zoom: map.getZoom() - 1,
76
+ around: map.unproject(zoomOutPoint)
77
+ }, {
78
+ originalEvent: e
79
+ });
80
+ }
81
+ };
82
+ }
83
+ }
84
+ }, {
85
+ key: "touchcancel",
86
+ value: function touchcancel() {
87
+ this.reset();
88
+ }
89
+ }, {
90
+ key: "enable",
91
+ value: function enable() {
92
+ this.enabled = true;
93
+ }
94
+ }, {
95
+ key: "disable",
96
+ value: function disable() {
97
+ this.enabled = false;
98
+ this.reset();
99
+ }
100
+ }, {
101
+ key: "isEnabled",
102
+ value: function isEnabled() {
103
+ return this.enabled;
104
+ }
105
+ }, {
106
+ key: "isActive",
107
+ value: function isActive() {
108
+ return this.active;
109
+ }
110
+ }]);
111
+
112
+ return TapZoomHandler;
113
+ }();
114
+
115
+ 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,128 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import Point from "../../geo/point";
5
+ import { indexTouches } from "../handler_util";
6
+
7
+ var TouchPanHandler = /*#__PURE__*/function () {
8
+ function TouchPanHandler(options) {
9
+ _classCallCheck(this, TouchPanHandler);
10
+
11
+ this.minTouches = 1;
12
+ this.clickTolerance = options.clickTolerance || 1;
13
+ this.reset();
14
+ }
15
+
16
+ _createClass(TouchPanHandler, [{
17
+ key: "reset",
18
+ value: function reset() {
19
+ this.active = false;
20
+ this.touches = {};
21
+ this.sum = new Point(0, 0);
22
+ }
23
+ }, {
24
+ key: "touchstart",
25
+ value: function touchstart(e, points, mapTouches) {
26
+ return this.calculateTransform(e, points, mapTouches);
27
+ }
28
+ }, {
29
+ key: "touchmove",
30
+ value: function touchmove(e, points, mapTouches) {
31
+ if (!this.active) {
32
+ return;
33
+ }
34
+
35
+ e.preventDefault();
36
+ return this.calculateTransform(e, points, mapTouches);
37
+ }
38
+ }, {
39
+ key: "touchend",
40
+ value: function touchend(e, points, mapTouches) {
41
+ this.calculateTransform(e, points, mapTouches);
42
+
43
+ if (this.active && mapTouches.length < this.minTouches) {
44
+ this.reset();
45
+ }
46
+ }
47
+ }, {
48
+ key: "touchcancel",
49
+ value: function touchcancel() {
50
+ this.reset();
51
+ }
52
+ }, {
53
+ key: "enable",
54
+ value: function enable() {
55
+ this.enabled = true;
56
+ }
57
+ }, {
58
+ key: "disable",
59
+ value: function disable() {
60
+ this.enabled = false;
61
+ this.reset();
62
+ }
63
+ }, {
64
+ key: "isEnabled",
65
+ value: function isEnabled() {
66
+ return this.enabled;
67
+ }
68
+ }, {
69
+ key: "isActive",
70
+ value: function isActive() {
71
+ return this.active;
72
+ }
73
+ }, {
74
+ key: "calculateTransform",
75
+ value: function calculateTransform(e, points, mapTouches) {
76
+ if (mapTouches.length > 0) {
77
+ this.active = true;
78
+ }
79
+
80
+ var touches = indexTouches(mapTouches, points);
81
+ var touchPointSum = new Point(0, 0);
82
+ var touchDeltaSum = new Point(0, 0);
83
+ var touchDeltaCount = 0;
84
+
85
+ for (var identifier in touches) {
86
+ if (touches[identifier]) {
87
+ var point = touches[identifier];
88
+ var prevPoint = this.touches[identifier];
89
+
90
+ if (prevPoint) {
91
+ touchPointSum._add(point);
92
+
93
+ touchDeltaSum._add(point.sub(prevPoint));
94
+
95
+ touchDeltaCount++;
96
+ touches[identifier] = point;
97
+ }
98
+ }
99
+ }
100
+
101
+ this.touches = touches;
102
+
103
+ if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
104
+ return;
105
+ } // @ts-ignore
106
+
107
+
108
+ var panDelta = touchDeltaSum.div(touchDeltaCount);
109
+
110
+ this.sum._add(panDelta);
111
+
112
+ if (this.sum.mag() < this.clickTolerance) {
113
+ return;
114
+ } // @ts-ignore
115
+
116
+
117
+ var around = touchPointSum.div(touchDeltaCount);
118
+ return {
119
+ around: around,
120
+ panDelta: panDelta
121
+ };
122
+ }
123
+ }]);
124
+
125
+ return TouchPanHandler;
126
+ }();
127
+
128
+ 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,110 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _get from "@babel/runtime/helpers/get";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+
8
+ 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); }; }
9
+
10
+ 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; } }
11
+
12
+ // @ts-ignore
13
+ import TwoTouchHandler from "./two_touch";
14
+
15
+ function isVertical(vector) {
16
+ return Math.abs(vector.y) > Math.abs(vector.x);
17
+ }
18
+
19
+ var ALLOWED_SINGLE_TOUCH_TIME = 100;
20
+
21
+ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
22
+ _inherits(TouchPitchHandler, _TwoTouchHandler);
23
+
24
+ var _super = _createSuper(TouchPitchHandler);
25
+
26
+ function TouchPitchHandler() {
27
+ _classCallCheck(this, TouchPitchHandler);
28
+
29
+ return _super.apply(this, arguments);
30
+ }
31
+
32
+ _createClass(TouchPitchHandler, [{
33
+ key: "reset",
34
+ value: function reset() {
35
+ _get(_getPrototypeOf(TouchPitchHandler.prototype), "reset", this).call(this);
36
+
37
+ this.valid = undefined; //@ts-ignore
38
+
39
+ delete this.firstMove; //@ts-ignore
40
+
41
+ delete this.lastPoints;
42
+ }
43
+ }, {
44
+ key: "start",
45
+ value: function start(points) {
46
+ this.lastPoints = points;
47
+
48
+ if (isVertical(points[0].sub(points[1]))) {
49
+ // fingers are more horizontal than vertical
50
+ this.valid = false;
51
+ }
52
+ }
53
+ }, {
54
+ key: "move",
55
+ value: function move(points, center, e) {
56
+ var vectorA = points[0].sub(this.lastPoints[0]);
57
+ var vectorB = points[1].sub(this.lastPoints[1]);
58
+ this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
59
+
60
+ if (!this.valid) {
61
+ return;
62
+ }
63
+
64
+ this.lastPoints = points;
65
+ this.active = true;
66
+ var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
67
+ var degreesPerPixelMoved = -0.5;
68
+ return {
69
+ pitchDelta: yDeltaAverage * degreesPerPixelMoved
70
+ };
71
+ }
72
+ }, {
73
+ key: "gestureBeginsVertically",
74
+ value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
75
+ if (this.valid !== undefined) {
76
+ return this.valid;
77
+ }
78
+
79
+ var threshold = 2;
80
+ var movedA = vectorA.mag() >= threshold;
81
+ var movedB = vectorB.mag() >= threshold; // neither finger has moved a meaningful amount, wait
82
+
83
+ if (!movedA && !movedB) {
84
+ return;
85
+ } // One finger has moved and the other has not.
86
+ // If enough time has passed, decide it is not a pitch.
87
+
88
+
89
+ if (!movedA || !movedB) {
90
+ if (this.firstMove === undefined) {
91
+ this.firstMove = timeStamp;
92
+ }
93
+
94
+ if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
95
+ // still waiting for a movement from the second finger
96
+ return undefined;
97
+ } else {
98
+ return false;
99
+ }
100
+ }
101
+
102
+ var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
103
+ return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
104
+ }
105
+ }]);
106
+
107
+ return TouchPitchHandler;
108
+ }(TwoTouchHandler);
109
+
110
+ 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,88 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _get from "@babel/runtime/helpers/get";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+
8
+ 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); }; }
9
+
10
+ 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; } }
11
+
12
+ // @ts-ignore
13
+ import TwoTouchHandler from "./two_touch";
14
+ var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
15
+
16
+ function getBearingDelta(a, b) {
17
+ return a.angleWith(b) * 180 / Math.PI;
18
+ }
19
+
20
+ var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
21
+ _inherits(TouchRotateHandler, _TwoTouchHandler);
22
+
23
+ var _super = _createSuper(TouchRotateHandler);
24
+
25
+ function TouchRotateHandler() {
26
+ _classCallCheck(this, TouchRotateHandler);
27
+
28
+ return _super.apply(this, arguments);
29
+ }
30
+
31
+ _createClass(TouchRotateHandler, [{
32
+ key: "reset",
33
+ value: function reset() {
34
+ _get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this); //@ts-ignore
35
+
36
+
37
+ delete this.minDiameter; //@ts-ignore
38
+
39
+ delete this.startVector; //@ts-ignore
40
+
41
+ delete this.vector;
42
+ }
43
+ }, {
44
+ key: "start",
45
+ value: function start(points) {
46
+ this.startVector = this.vector = points[0].sub(points[1]);
47
+ this.minDiameter = points[0].dist(points[1]);
48
+ }
49
+ }, {
50
+ key: "move",
51
+ value: function move(points, pinchAround) {
52
+ var lastVector = this.vector;
53
+ this.vector = points[0].sub(points[1]);
54
+
55
+ if (!this.active && this.isBelowThreshold(this.vector)) {
56
+ return;
57
+ }
58
+
59
+ this.active = true;
60
+ return {
61
+ bearingDelta: getBearingDelta(this.vector, lastVector),
62
+ pinchAround: pinchAround
63
+ };
64
+ }
65
+ }, {
66
+ key: "isBelowThreshold",
67
+ value: function isBelowThreshold(vector) {
68
+ /*
69
+ * The threshold before a rotation actually happens is configured in
70
+ * pixels alongth circumference of the circle formed by the two fingers.
71
+ * This makes the threshold in degrees larger when the fingers are close
72
+ * together and smaller when the fingers are far apart.
73
+ *
74
+ * Use the smallest diameter from the whole gesture to reduce sensitivity
75
+ * when pinching in and out.
76
+ */
77
+ this.minDiameter = Math.min(this.minDiameter, vector.mag());
78
+ var circumference = Math.PI * this.minDiameter;
79
+ var threshold = ROTATION_THRESHOLD / circumference * 360;
80
+ var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
81
+ return Math.abs(bearingDeltaSinceStart) < threshold;
82
+ }
83
+ }]);
84
+
85
+ return TouchRotateHandler;
86
+ }(TwoTouchHandler);
87
+
88
+ 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
+ }