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