@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,36 @@
1
+ import { EarthMap } from '../earthmap';
2
+ import { Map } from '../map';
3
+ /**
4
+ * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using
5
+ * the following keyboard shortcuts:
6
+ *
7
+ * - `=` / `+`: Increase the zoom level by 1.
8
+ * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.
9
+ * - `-`: Decrease the zoom level by 1.
10
+ * - `Shift--`: Decrease the zoom level by 2.
11
+ * - Arrow keys: Pan by 100 pixels.
12
+ * - `Shift+⇢`: Increase the rotation by 15 degrees.
13
+ * - `Shift+⇠`: Decrease the rotation by 15 degrees.
14
+ * - `Shift+⇡`: Increase the pitch by 10 degrees.
15
+ * - `Shift+⇣`: Decrease the pitch by 10 degrees.
16
+ */
17
+ declare class KeyboardHandler {
18
+ private enabled;
19
+ private active;
20
+ private panStep;
21
+ private bearingStep;
22
+ private pitchStep;
23
+ /**
24
+ * @private
25
+ */
26
+ constructor();
27
+ reset(): void;
28
+ keydown(e: KeyboardEvent): {
29
+ cameraAnimation: (map: Map | EarthMap) => void;
30
+ } | undefined;
31
+ enable(): void;
32
+ disable(): void;
33
+ isEnabled(): boolean;
34
+ isActive(): boolean;
35
+ }
36
+ export default KeyboardHandler;
@@ -0,0 +1,162 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ var defaultOptions = {
4
+ panStep: 100,
5
+ bearingStep: 15,
6
+ pitchStep: 10
7
+ };
8
+ /**
9
+ * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using
10
+ * the following keyboard shortcuts:
11
+ *
12
+ * - `=` / `+`: Increase the zoom level by 1.
13
+ * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.
14
+ * - `-`: Decrease the zoom level by 1.
15
+ * - `Shift--`: Decrease the zoom level by 2.
16
+ * - Arrow keys: Pan by 100 pixels.
17
+ * - `Shift+⇢`: Increase the rotation by 15 degrees.
18
+ * - `Shift+⇠`: Decrease the rotation by 15 degrees.
19
+ * - `Shift+⇡`: Increase the pitch by 10 degrees.
20
+ * - `Shift+⇣`: Decrease the pitch by 10 degrees.
21
+ */
22
+
23
+ var KeyboardHandler = /*#__PURE__*/function () {
24
+ /**
25
+ * @private
26
+ */
27
+ function KeyboardHandler() {
28
+ _classCallCheck(this, KeyboardHandler);
29
+
30
+ var stepOptions = defaultOptions;
31
+ this.panStep = stepOptions.panStep;
32
+ this.bearingStep = stepOptions.bearingStep;
33
+ this.pitchStep = stepOptions.pitchStep;
34
+ }
35
+
36
+ _createClass(KeyboardHandler, [{
37
+ key: "reset",
38
+ value: function reset() {
39
+ this.active = false;
40
+ }
41
+ }, {
42
+ key: "keydown",
43
+ value: function keydown(e) {
44
+ var _this = this;
45
+
46
+ if (e.altKey || e.ctrlKey || e.metaKey) {
47
+ return;
48
+ }
49
+
50
+ var zoomDir = 0;
51
+ var bearingDir = 0;
52
+ var pitchDir = 0;
53
+ var xDir = 0;
54
+ var yDir = 0;
55
+
56
+ switch (e.keyCode) {
57
+ case 61:
58
+ case 107:
59
+ case 171:
60
+ case 187:
61
+ zoomDir = 1;
62
+ break;
63
+
64
+ case 189:
65
+ case 109:
66
+ case 173:
67
+ zoomDir = -1;
68
+ break;
69
+
70
+ case 37:
71
+ if (e.shiftKey) {
72
+ bearingDir = -1;
73
+ } else {
74
+ e.preventDefault();
75
+ xDir = -1;
76
+ }
77
+
78
+ break;
79
+
80
+ case 39:
81
+ if (e.shiftKey) {
82
+ bearingDir = 1;
83
+ } else {
84
+ e.preventDefault();
85
+ xDir = 1;
86
+ }
87
+
88
+ break;
89
+
90
+ case 38:
91
+ if (e.shiftKey) {
92
+ pitchDir = 1;
93
+ } else {
94
+ e.preventDefault();
95
+ yDir = -1;
96
+ }
97
+
98
+ break;
99
+
100
+ case 40:
101
+ if (e.shiftKey) {
102
+ pitchDir = -1;
103
+ } else {
104
+ e.preventDefault();
105
+ yDir = 1;
106
+ }
107
+
108
+ break;
109
+
110
+ default:
111
+ return;
112
+ }
113
+
114
+ return {
115
+ cameraAnimation: function cameraAnimation(map) {
116
+ var zoom = map.getZoom();
117
+ map.easeTo({
118
+ duration: 300,
119
+ easeId: 'keyboardHandler',
120
+ easing: easeOut,
121
+ zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
122
+ bearing: map.getBearing() + bearingDir * _this.bearingStep,
123
+ pitch: map.getPitch() + pitchDir * _this.pitchStep,
124
+ offset: [-xDir * _this.panStep, -yDir * _this.panStep],
125
+ center: map.getCenter()
126
+ }, {
127
+ originalEvent: e
128
+ });
129
+ }
130
+ };
131
+ }
132
+ }, {
133
+ key: "enable",
134
+ value: function enable() {
135
+ this.enabled = true;
136
+ }
137
+ }, {
138
+ key: "disable",
139
+ value: function disable() {
140
+ this.enabled = false;
141
+ this.reset();
142
+ }
143
+ }, {
144
+ key: "isEnabled",
145
+ value: function isEnabled() {
146
+ return this.enabled;
147
+ }
148
+ }, {
149
+ key: "isActive",
150
+ value: function isActive() {
151
+ return this.active;
152
+ }
153
+ }]);
154
+
155
+ return KeyboardHandler;
156
+ }();
157
+
158
+ function easeOut(t) {
159
+ return t * (2 - t);
160
+ }
161
+
162
+ export default KeyboardHandler;
@@ -0,0 +1,29 @@
1
+ import { EarthMap } from '../earthmap';
2
+ import Point from '../geo/point';
3
+ import { Map } from '../map';
4
+ import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from './events';
5
+ export default class MapEventHandler {
6
+ private mousedownPos;
7
+ private clickTolerance;
8
+ private map;
9
+ constructor(map: Map | EarthMap, options: {
10
+ clickTolerance: number;
11
+ });
12
+ reset(): void;
13
+ wheel(e: WheelEvent): {} | undefined;
14
+ mousedown(e: MouseEvent, point: Point): {} | undefined;
15
+ mouseup(e: MouseEvent): void;
16
+ click(e: MouseEvent, point: Point): void;
17
+ dblclick(e: MouseEvent): {} | undefined;
18
+ mouseover(e: MouseEvent): void;
19
+ mouseout(e: MouseEvent): void;
20
+ touchstart(e: TouchEvent): {} | undefined;
21
+ touchmove(e: TouchEvent): void;
22
+ touchend(e: TouchEvent): void;
23
+ touchcancel(e: TouchEvent): void;
24
+ firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent): {} | undefined;
25
+ isEnabled(): boolean;
26
+ isActive(): boolean;
27
+ enable(): boolean;
28
+ disable(): boolean;
29
+ }
@@ -0,0 +1,131 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from "./events";
5
+
6
+ var MapEventHandler = /*#__PURE__*/function () {
7
+ function MapEventHandler(map, options) {
8
+ _classCallCheck(this, MapEventHandler);
9
+
10
+ this.map = map;
11
+ this.clickTolerance = options.clickTolerance;
12
+ }
13
+
14
+ _createClass(MapEventHandler, [{
15
+ key: "reset",
16
+ value: function reset() {
17
+ // @ts-ignore
18
+ delete this.mousedownPos;
19
+ }
20
+ }, {
21
+ key: "wheel",
22
+ value: function wheel(e) {
23
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
24
+ // - ScrollZoom
25
+ return this.firePreventable(new MapWheelEvent(e.type, this.map, e));
26
+ }
27
+ }, {
28
+ key: "mousedown",
29
+ value: function mousedown(e, point) {
30
+ this.mousedownPos = point; // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
31
+ // - MousePan
32
+ // - MouseRotate
33
+ // - MousePitch
34
+ // - DblclickHandler
35
+
36
+ return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
37
+ }
38
+ }, {
39
+ key: "mouseup",
40
+ value: function mouseup(e) {
41
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
42
+ }
43
+ }, {
44
+ key: "click",
45
+ value: function click(e, point) {
46
+ if (this.mousedownPos && this.mousedownPos.dist(point) >= this.clickTolerance) {
47
+ return;
48
+ }
49
+
50
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
51
+ }
52
+ }, {
53
+ key: "dblclick",
54
+ value: function dblclick(e) {
55
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
56
+ // - DblClickZoom
57
+ return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
58
+ }
59
+ }, {
60
+ key: "mouseover",
61
+ value: function mouseover(e) {
62
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
63
+ }
64
+ }, {
65
+ key: "mouseout",
66
+ value: function mouseout(e) {
67
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
68
+ }
69
+ }, {
70
+ key: "touchstart",
71
+ value: function touchstart(e) {
72
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
73
+ // - TouchPan
74
+ // - TouchZoom
75
+ // - TouchRotate
76
+ // - TouchPitch
77
+ // - TapZoom
78
+ // - SwipeZoom
79
+ return this.firePreventable(new MapTouchEvent(e.type, this.map, e));
80
+ }
81
+ }, {
82
+ key: "touchmove",
83
+ value: function touchmove(e) {
84
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
85
+ }
86
+ }, {
87
+ key: "touchend",
88
+ value: function touchend(e) {
89
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
90
+ }
91
+ }, {
92
+ key: "touchcancel",
93
+ value: function touchcancel(e) {
94
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
95
+ }
96
+ }, {
97
+ key: "firePreventable",
98
+ value: function firePreventable(mapEvent) {
99
+ this.map.emit(mapEvent.type, mapEvent);
100
+
101
+ if (mapEvent.defaultPrevented) {
102
+ // returning an object marks the handler as active and resets other handlers
103
+ return {};
104
+ }
105
+ }
106
+ }, {
107
+ key: "isEnabled",
108
+ value: function isEnabled() {
109
+ return true;
110
+ }
111
+ }, {
112
+ key: "isActive",
113
+ value: function isActive() {
114
+ return false;
115
+ }
116
+ }, {
117
+ key: "enable",
118
+ value: function enable() {
119
+ return false;
120
+ }
121
+ }, {
122
+ key: "disable",
123
+ value: function disable() {
124
+ return false;
125
+ }
126
+ }]);
127
+
128
+ return MapEventHandler;
129
+ }();
130
+
131
+ export { MapEventHandler as default };
@@ -0,0 +1,4 @@
1
+ import MousePanHandler from './mousepan_handler';
2
+ import MouseRotateHandler from './mousepitch_hander';
3
+ import MousePitchHandler from './mouserotate_hander';
4
+ export { MousePanHandler, MouseRotateHandler, MousePitchHandler };
@@ -0,0 +1,4 @@
1
+ import MousePanHandler from "./mousepan_handler";
2
+ import MouseRotateHandler from "./mousepitch_hander";
3
+ import MousePitchHandler from "./mouserotate_hander";
4
+ export { MousePanHandler, MouseRotateHandler, MousePitchHandler };
@@ -0,0 +1,22 @@
1
+ import Point from '../../geo/point';
2
+ export default class MouseHandler {
3
+ protected enabled: boolean;
4
+ protected active: boolean;
5
+ protected lastPoint: Point;
6
+ protected eventButton: 1 | 2;
7
+ protected moved: boolean;
8
+ protected clickTolerance: number;
9
+ constructor(options: {
10
+ clickTolerance: number;
11
+ });
12
+ reset(): void;
13
+ mousedown(e: MouseEvent, point: Point): void;
14
+ mousemoveWindow(e: MouseEvent, point: Point): void;
15
+ mouseupWindow(e: MouseEvent): void;
16
+ enable(): void;
17
+ disable(): void;
18
+ isEnabled(): boolean;
19
+ isActive(): boolean;
20
+ protected correctButton(e: MouseEvent, button: number): boolean;
21
+ protected move(lastPoint: Point, point: Point): void;
22
+ }
@@ -0,0 +1,131 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import DOM from "../../utils/dom";
5
+ import { buttonStillPressed } from "./util";
6
+
7
+ var MouseHandler = /*#__PURE__*/function () {
8
+ function MouseHandler(options) {
9
+ _classCallCheck(this, MouseHandler);
10
+
11
+ this.reset();
12
+ this.clickTolerance = options.clickTolerance || 1;
13
+ }
14
+
15
+ _createClass(MouseHandler, [{
16
+ key: "reset",
17
+ value: function reset() {
18
+ this.active = false;
19
+ this.moved = false; //@ts-ignore
20
+
21
+ delete this.lastPoint; //@ts-ignore
22
+
23
+ delete this.eventButton;
24
+ }
25
+ }, {
26
+ key: "mousedown",
27
+ value: function mousedown(e, point) {
28
+ if (this.lastPoint) {
29
+ return;
30
+ }
31
+
32
+ var eventButton = DOM.mouseButton(e);
33
+
34
+ if (!this.correctButton(e, eventButton)) {
35
+ return;
36
+ }
37
+
38
+ this.lastPoint = point;
39
+ this.eventButton = eventButton;
40
+ }
41
+ }, {
42
+ key: "mousemoveWindow",
43
+ value: function mousemoveWindow(e, point) {
44
+ var lastPoint = this.lastPoint;
45
+
46
+ if (!lastPoint) {
47
+ return;
48
+ }
49
+
50
+ e.preventDefault();
51
+
52
+ if (buttonStillPressed(e, this.eventButton)) {
53
+ // Some browsers don't fire a `mouseup` when the mouseup occurs outside
54
+ // the window or iframe:
55
+ // https://github.com/mapbox/mapbox-gl-js/issues/4622
56
+ //
57
+ // If the button is no longer pressed during this `mousemove` it may have
58
+ // been released outside of the window or iframe.
59
+ this.reset();
60
+ return;
61
+ }
62
+
63
+ if (!this.moved && point.dist(lastPoint) < this.clickTolerance) {
64
+ return;
65
+ }
66
+
67
+ this.moved = true;
68
+ this.lastPoint = point; // implemented by child class
69
+
70
+ return this.move(lastPoint, point);
71
+ }
72
+ }, {
73
+ key: "mouseupWindow",
74
+ value: function mouseupWindow(e) {
75
+ if (!this.lastPoint) {
76
+ return;
77
+ }
78
+
79
+ var eventButton = DOM.mouseButton(e);
80
+
81
+ if (eventButton !== this.eventButton) {
82
+ return;
83
+ }
84
+
85
+ if (this.moved) {
86
+ DOM.suppressClick();
87
+ }
88
+
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
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
+
113
+ }, {
114
+ key: "correctButton",
115
+ value: function correctButton(e, button) {
116
+ // eslint-disable-line
117
+ return false; // implemented by child
118
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
119
+
120
+ }, {
121
+ key: "move",
122
+ value: function move(lastPoint, point) {
123
+ // eslint-disable-line
124
+ return; // implemented by child
125
+ }
126
+ }]);
127
+
128
+ return MouseHandler;
129
+ }();
130
+
131
+ export { MouseHandler as default };
@@ -0,0 +1,10 @@
1
+ import Point from '../../geo/point';
2
+ import MouseHandler from './mouse_handler';
3
+ export default class MousePanHandler extends MouseHandler {
4
+ mousedown(e: MouseEvent, point: Point): void;
5
+ move(lastPoint: Point, point: Point): {
6
+ around: Point;
7
+ panDelta: Point;
8
+ };
9
+ protected correctButton(e: MouseEvent, button: number): boolean;
10
+ }
@@ -0,0 +1,54 @@
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 MouseHandler from "./mouse_handler";
14
+ import { LEFT_BUTTON } from "./util";
15
+
16
+ var MousePanHandler = /*#__PURE__*/function (_MouseHandler) {
17
+ _inherits(MousePanHandler, _MouseHandler);
18
+
19
+ var _super = _createSuper(MousePanHandler);
20
+
21
+ function MousePanHandler() {
22
+ _classCallCheck(this, MousePanHandler);
23
+
24
+ return _super.apply(this, arguments);
25
+ }
26
+
27
+ _createClass(MousePanHandler, [{
28
+ key: "mousedown",
29
+ value: function mousedown(e, point) {
30
+ _get(_getPrototypeOf(MousePanHandler.prototype), "mousedown", this).call(this, e, point);
31
+
32
+ if (this.lastPoint) {
33
+ this.active = true;
34
+ }
35
+ }
36
+ }, {
37
+ key: "move",
38
+ value: function move(lastPoint, point) {
39
+ return {
40
+ around: point,
41
+ panDelta: point.sub(lastPoint)
42
+ };
43
+ }
44
+ }, {
45
+ key: "correctButton",
46
+ value: function correctButton(e, button) {
47
+ return button === LEFT_BUTTON && !e.ctrlKey;
48
+ }
49
+ }]);
50
+
51
+ return MousePanHandler;
52
+ }(MouseHandler);
53
+
54
+ export { MousePanHandler as default };
@@ -0,0 +1,9 @@
1
+ import Point from '../../geo/point';
2
+ import MouseHandler from './mouse_handler';
3
+ export default class MousePitchHandler extends MouseHandler {
4
+ correctButton(e: MouseEvent, button: number): boolean;
5
+ move(lastPoint: Point, point: Point): {
6
+ pitchDelta: number;
7
+ } | undefined;
8
+ contextmenu(e: MouseEvent): void;
9
+ }
@@ -0,0 +1,56 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
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
+
9
+ 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; } }
10
+
11
+ // @ts-ignore
12
+ import MouseHandler from "./mouse_handler";
13
+ import { LEFT_BUTTON, RIGHT_BUTTON } from "./util";
14
+
15
+ var MousePitchHandler = /*#__PURE__*/function (_MouseHandler) {
16
+ _inherits(MousePitchHandler, _MouseHandler);
17
+
18
+ var _super = _createSuper(MousePitchHandler);
19
+
20
+ function MousePitchHandler() {
21
+ _classCallCheck(this, MousePitchHandler);
22
+
23
+ return _super.apply(this, arguments);
24
+ }
25
+
26
+ _createClass(MousePitchHandler, [{
27
+ key: "correctButton",
28
+ value: function correctButton(e, button) {
29
+ return button === LEFT_BUTTON && e.ctrlKey || button === RIGHT_BUTTON;
30
+ }
31
+ }, {
32
+ key: "move",
33
+ value: function move(lastPoint, point) {
34
+ var degreesPerPixelMoved = -0.5;
35
+ var pitchDelta = (point.y - lastPoint.y) * degreesPerPixelMoved;
36
+
37
+ if (pitchDelta) {
38
+ this.active = true;
39
+ return {
40
+ pitchDelta: pitchDelta
41
+ };
42
+ }
43
+ }
44
+ }, {
45
+ key: "contextmenu",
46
+ value: function contextmenu(e) {
47
+ // prevent browser context menu when necessary; we don't allow it with rotation
48
+ // because we can't discern rotation gesture start from contextmenu on Mac
49
+ e.preventDefault();
50
+ }
51
+ }]);
52
+
53
+ return MousePitchHandler;
54
+ }(MouseHandler);
55
+
56
+ export { MousePitchHandler as default };
@@ -0,0 +1,9 @@
1
+ import Point from '../../geo/point';
2
+ import MouseHandler from './mouse_handler';
3
+ export default class MouseRotateHandler extends MouseHandler {
4
+ contextmenu(e: MouseEvent): void;
5
+ protected correctButton(e: MouseEvent, button: number): boolean;
6
+ protected move(lastPoint: Point, point: Point): {
7
+ bearingDelta: number;
8
+ } | undefined;
9
+ }