@antv/l7-map 2.25.5 → 2.25.7

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 (159) hide show
  1. package/package.json +2 -2
  2. package/es/index.d.ts +0 -5
  3. package/es/index.js +0 -4
  4. package/es/map/camera.d.ts +0 -690
  5. package/es/map/camera.js +0 -1138
  6. package/es/map/css/l7.css +0 -171
  7. package/es/map/events.d.ts +0 -384
  8. package/es/map/events.js +0 -231
  9. package/es/map/geo/edge_insets.d.ts +0 -97
  10. package/es/map/geo/edge_insets.js +0 -115
  11. package/es/map/geo/lng_lat.d.ts +0 -116
  12. package/es/map/geo/lng_lat.js +0 -159
  13. package/es/map/geo/lng_lat_bounds.d.ts +0 -217
  14. package/es/map/geo/lng_lat_bounds.js +0 -334
  15. package/es/map/geo/mercator_coordinate.d.ts +0 -113
  16. package/es/map/geo/mercator_coordinate.js +0 -142
  17. package/es/map/geo/transform.d.ts +0 -262
  18. package/es/map/geo/transform.js +0 -736
  19. package/es/map/handler/box_zoom.d.ts +0 -65
  20. package/es/map/handler/box_zoom.js +0 -145
  21. package/es/map/handler/click_zoom.d.ts +0 -24
  22. package/es/map/handler/click_zoom.js +0 -47
  23. package/es/map/handler/cooperative_gestures.d.ts +0 -40
  24. package/es/map/handler/cooperative_gestures.js +0 -94
  25. package/es/map/handler/drag_handler.d.ts +0 -88
  26. package/es/map/handler/drag_handler.js +0 -89
  27. package/es/map/handler/drag_move_state_manager.d.ts +0 -30
  28. package/es/map/handler/drag_move_state_manager.js +0 -94
  29. package/es/map/handler/handler_util.d.ts +0 -3
  30. package/es/map/handler/handler_util.js +0 -8
  31. package/es/map/handler/keyboard.d.ts +0 -88
  32. package/es/map/handler/keyboard.js +0 -197
  33. package/es/map/handler/map_event.d.ts +0 -46
  34. package/es/map/handler/map_event.js +0 -131
  35. package/es/map/handler/mouse.d.ts +0 -30
  36. package/es/map/handler/mouse.js +0 -85
  37. package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
  38. package/es/map/handler/one_finger_touch_drag.js +0 -39
  39. package/es/map/handler/scroll_zoom.d.ts +0 -102
  40. package/es/map/handler/scroll_zoom.js +0 -312
  41. package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
  42. package/es/map/handler/shim/dblclick_zoom.js +0 -60
  43. package/es/map/handler/shim/drag_pan.d.ts +0 -79
  44. package/es/map/handler/shim/drag_pan.js +0 -77
  45. package/es/map/handler/shim/drag_rotate.d.ts +0 -54
  46. package/es/map/handler/shim/drag_rotate.js +0 -66
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
  48. package/es/map/handler/shim/two_fingers_touch.js +0 -106
  49. package/es/map/handler/tap_drag_zoom.d.ts +0 -28
  50. package/es/map/handler/tap_drag_zoom.js +0 -92
  51. package/es/map/handler/tap_recognizer.d.ts +0 -35
  52. package/es/map/handler/tap_recognizer.js +0 -107
  53. package/es/map/handler/tap_zoom.d.ts +0 -28
  54. package/es/map/handler/tap_zoom.js +0 -87
  55. package/es/map/handler/touch_pan.d.ts +0 -40
  56. package/es/map/handler/touch_pan.js +0 -85
  57. package/es/map/handler/transform-provider.d.ts +0 -23
  58. package/es/map/handler/transform-provider.js +0 -35
  59. package/es/map/handler/two_fingers_touch.d.ts +0 -107
  60. package/es/map/handler/two_fingers_touch.js +0 -289
  61. package/es/map/handler_inertia.d.ts +0 -20
  62. package/es/map/handler_inertia.js +0 -128
  63. package/es/map/handler_manager.d.ts +0 -154
  64. package/es/map/handler_manager.js +0 -466
  65. package/es/map/map.d.ts +0 -637
  66. package/es/map/map.js +0 -984
  67. package/es/map/util/abort_error.d.ts +0 -15
  68. package/es/map/util/abort_error.js +0 -21
  69. package/es/map/util/browser.d.ts +0 -10
  70. package/es/map/util/browser.js +0 -30
  71. package/es/map/util/dom.d.ts +0 -30
  72. package/es/map/util/dom.js +0 -105
  73. package/es/map/util/evented.d.ts +0 -75
  74. package/es/map/util/evented.js +0 -158
  75. package/es/map/util/simpleMapCoord.d.ts +0 -31
  76. package/es/map/util/simpleMapCoord.js +0 -54
  77. package/es/map/util/task_queue.d.ts +0 -18
  78. package/es/map/util/task_queue.js +0 -54
  79. package/es/map/util/util.d.ts +0 -104
  80. package/es/map/util/util.js +0 -155
  81. package/lib/index.d.ts +0 -5
  82. package/lib/index.js +0 -33
  83. package/lib/map/camera.d.ts +0 -690
  84. package/lib/map/camera.js +0 -1145
  85. package/lib/map/css/l7.css +0 -171
  86. package/lib/map/events.d.ts +0 -384
  87. package/lib/map/events.js +0 -240
  88. package/lib/map/geo/edge_insets.d.ts +0 -97
  89. package/lib/map/geo/edge_insets.js +0 -122
  90. package/lib/map/geo/lng_lat.d.ts +0 -116
  91. package/lib/map/geo/lng_lat.js +0 -166
  92. package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
  93. package/lib/map/geo/lng_lat_bounds.js +0 -341
  94. package/lib/map/geo/mercator_coordinate.d.ts +0 -113
  95. package/lib/map/geo/mercator_coordinate.js +0 -157
  96. package/lib/map/geo/transform.d.ts +0 -262
  97. package/lib/map/geo/transform.js +0 -744
  98. package/lib/map/handler/box_zoom.d.ts +0 -65
  99. package/lib/map/handler/box_zoom.js +0 -153
  100. package/lib/map/handler/click_zoom.d.ts +0 -24
  101. package/lib/map/handler/click_zoom.js +0 -54
  102. package/lib/map/handler/cooperative_gestures.d.ts +0 -40
  103. package/lib/map/handler/cooperative_gestures.js +0 -101
  104. package/lib/map/handler/drag_handler.d.ts +0 -88
  105. package/lib/map/handler/drag_handler.js +0 -97
  106. package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
  107. package/lib/map/handler/drag_move_state_manager.js +0 -103
  108. package/lib/map/handler/handler_util.d.ts +0 -3
  109. package/lib/map/handler/handler_util.js +0 -14
  110. package/lib/map/handler/keyboard.d.ts +0 -88
  111. package/lib/map/handler/keyboard.js +0 -205
  112. package/lib/map/handler/map_event.d.ts +0 -46
  113. package/lib/map/handler/map_event.js +0 -140
  114. package/lib/map/handler/mouse.d.ts +0 -30
  115. package/lib/map/handler/mouse.js +0 -93
  116. package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
  117. package/lib/map/handler/one_finger_touch_drag.js +0 -47
  118. package/lib/map/handler/scroll_zoom.d.ts +0 -102
  119. package/lib/map/handler/scroll_zoom.js +0 -320
  120. package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
  121. package/lib/map/handler/shim/dblclick_zoom.js +0 -68
  122. package/lib/map/handler/shim/drag_pan.d.ts +0 -79
  123. package/lib/map/handler/shim/drag_pan.js +0 -85
  124. package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
  125. package/lib/map/handler/shim/drag_rotate.js +0 -74
  126. package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
  127. package/lib/map/handler/shim/two_fingers_touch.js +0 -114
  128. package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
  129. package/lib/map/handler/tap_drag_zoom.js +0 -99
  130. package/lib/map/handler/tap_recognizer.d.ts +0 -35
  131. package/lib/map/handler/tap_recognizer.js +0 -116
  132. package/lib/map/handler/tap_zoom.d.ts +0 -28
  133. package/lib/map/handler/tap_zoom.js +0 -94
  134. package/lib/map/handler/touch_pan.d.ts +0 -40
  135. package/lib/map/handler/touch_pan.js +0 -92
  136. package/lib/map/handler/transform-provider.d.ts +0 -23
  137. package/lib/map/handler/transform-provider.js +0 -43
  138. package/lib/map/handler/two_fingers_touch.d.ts +0 -107
  139. package/lib/map/handler/two_fingers_touch.js +0 -296
  140. package/lib/map/handler_inertia.d.ts +0 -20
  141. package/lib/map/handler_inertia.js +0 -136
  142. package/lib/map/handler_manager.d.ts +0 -154
  143. package/lib/map/handler_manager.js +0 -474
  144. package/lib/map/map.d.ts +0 -637
  145. package/lib/map/map.js +0 -991
  146. package/lib/map/util/abort_error.d.ts +0 -15
  147. package/lib/map/util/abort_error.js +0 -29
  148. package/lib/map/util/browser.d.ts +0 -10
  149. package/lib/map/util/browser.js +0 -36
  150. package/lib/map/util/dom.d.ts +0 -30
  151. package/lib/map/util/dom.js +0 -113
  152. package/lib/map/util/evented.d.ts +0 -75
  153. package/lib/map/util/evented.js +0 -167
  154. package/lib/map/util/simpleMapCoord.d.ts +0 -31
  155. package/lib/map/util/simpleMapCoord.js +0 -62
  156. package/lib/map/util/task_queue.d.ts +0 -18
  157. package/lib/map/util/task_queue.js +0 -62
  158. package/lib/map/util/util.d.ts +0 -104
  159. package/lib/map/util/util.js +0 -171
@@ -1,94 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { DOM } from "../util/dom";
3
- const LEFT_BUTTON = 0;
4
- const RIGHT_BUTTON = 2;
5
-
6
- // the values for each button in MouseEvent.buttons
7
- const BUTTONS_FLAGS = {
8
- [LEFT_BUTTON]: 1,
9
- [RIGHT_BUTTON]: 2
10
- };
11
- function buttonNoLongerPressed(e, button) {
12
- const flag = BUTTONS_FLAGS[button];
13
- return e.buttons === undefined || (e.buttons & flag) !== flag;
14
- }
15
-
16
- /*
17
- * Drag events are initiated by specific interaction which needs to be tracked until it ends.
18
- * This requires some state management:
19
- * 1. registering the initiating event,
20
- * 2. tracking that it was not canceled / not confusing it with another event firing.
21
- * 3. recognizing the ending event and cleaning up any internal state
22
- *
23
- * Concretely, we implement two state managers:
24
- * 1. MouseMoveStateManager
25
- * Receives a functions that is used to recognize mouse events that should be registered as the
26
- * relevant drag interactions - i.e. dragging with the right mouse button, or while CTRL is pressed.
27
- * 2. OneFingerTouchMoveStateManager
28
- * Checks if a drag event is using one finger, and continuously tracking that this is the same event
29
- * (i.e. to make sure not additional finger has started interacting with the screen before raising
30
- * the first finger).
31
- */
32
-
33
- export class MouseMoveStateManager {
34
- constructor(options) {
35
- _defineProperty(this, "_eventButton", void 0);
36
- _defineProperty(this, "_correctEvent", void 0);
37
- this._correctEvent = options.checkCorrectEvent;
38
- }
39
- startMove(e) {
40
- const eventButton = DOM.mouseButton(e);
41
- this._eventButton = eventButton;
42
- }
43
-
44
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
- endMove(_e) {
46
- delete this._eventButton;
47
- }
48
- isValidStartEvent(e) {
49
- return this._correctEvent(e);
50
- }
51
- isValidMoveEvent(e) {
52
- // Some browsers don't fire a `mouseup` when the mouseup occurs outside
53
- // the window or iframe:
54
- // https://github.com/mapbox/mapbox-gl-js/issues/4622
55
- //
56
- // If the button is no longer pressed during this `mousemove` it may have
57
- // been released outside of the window or iframe.
58
- return !buttonNoLongerPressed(e, this._eventButton);
59
- }
60
- isValidEndEvent(e) {
61
- const eventButton = DOM.mouseButton(e);
62
- return eventButton === this._eventButton;
63
- }
64
- }
65
- export class OneFingerTouchMoveStateManager {
66
- constructor() {
67
- _defineProperty(this, "_firstTouch", void 0);
68
- this._firstTouch = undefined;
69
- }
70
- _isOneFingerTouch(e) {
71
- return e.targetTouches.length === 1;
72
- }
73
- _isSameTouchEvent(e) {
74
- return e.targetTouches[0].identifier === this._firstTouch;
75
- }
76
- startMove(e) {
77
- const firstTouch = e.targetTouches[0].identifier;
78
- this._firstTouch = firstTouch;
79
- }
80
-
81
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
- endMove(_e) {
83
- delete this._firstTouch;
84
- }
85
- isValidStartEvent(e) {
86
- return this._isOneFingerTouch(e);
87
- }
88
- isValidMoveEvent(e) {
89
- return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);
90
- }
91
- isValidEndEvent(e) {
92
- return this._isOneFingerTouch(e) && this._isSameTouchEvent(e);
93
- }
94
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="mapbox__point-geometry" />
2
- import type Point from '@mapbox/point-geometry';
3
- export declare function indexTouches(touches: Array<Touch>, points: Array<Point>): {};
@@ -1,8 +0,0 @@
1
- export function indexTouches(touches, points) {
2
- if (touches.length !== points.length) throw new Error(`The number of touches and points are not equal - touches ${touches.length}, points ${points.length}`);
3
- const obj = {};
4
- for (let i = 0; i < touches.length; i++) {
5
- obj[touches[i].identifier] = points[i];
6
- }
7
- return obj;
8
- }
@@ -1,88 +0,0 @@
1
- import type { Handler } from '../handler_manager';
2
- import type { Map } from '../map';
3
- import { TransformProvider } from './transform-provider';
4
- /**
5
- * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using
6
- * the following keyboard shortcuts:
7
- *
8
- * - `=` / `+`: Increase the zoom level by 1.
9
- * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.
10
- * - `-`: Decrease the zoom level by 1.
11
- * - `Shift--`: Decrease the zoom level by 2.
12
- * - Arrow keys: Pan by 100 pixels.
13
- * - `Shift+⇢`: Increase the rotation by 15 degrees.
14
- * - `Shift+⇠`: Decrease the rotation by 15 degrees.
15
- * - `Shift+⇡`: Increase the pitch by 10 degrees.
16
- * - `Shift+⇣`: Decrease the pitch by 10 degrees.
17
- *
18
- * @group Handlers
19
- */
20
- export declare class KeyboardHandler implements Handler {
21
- _tr: TransformProvider;
22
- _enabled: boolean;
23
- _active: boolean;
24
- _panStep: number;
25
- _bearingStep: number;
26
- _pitchStep: number;
27
- _rotationDisabled: boolean;
28
- /** @internal */
29
- constructor(map: Map);
30
- reset(): void;
31
- keydown(e: KeyboardEvent): {
32
- cameraAnimation: (map: Map) => void;
33
- };
34
- /**
35
- * Enables the "keyboard rotate and zoom" interaction.
36
- *
37
- * @example
38
- * ```ts
39
- * map.keyboard.enable();
40
- * ```
41
- */
42
- enable(): void;
43
- /**
44
- * Disables the "keyboard rotate and zoom" interaction.
45
- *
46
- * @example
47
- * ```ts
48
- * map.keyboard.disable();
49
- * ```
50
- */
51
- disable(): void;
52
- /**
53
- * Returns a Boolean indicating whether the "keyboard rotate and zoom"
54
- * interaction is enabled.
55
- *
56
- * @returns `true` if the "keyboard rotate and zoom"
57
- * interaction is enabled.
58
- */
59
- isEnabled(): boolean;
60
- /**
61
- * Returns true if the handler is enabled and has detected the start of a
62
- * zoom/rotate gesture.
63
- *
64
- * @returns `true` if the handler is enabled and has detected the
65
- * start of a zoom/rotate gesture.
66
- */
67
- isActive(): boolean;
68
- /**
69
- * Disables the "keyboard pan/rotate" interaction, leaving the
70
- * "keyboard zoom" interaction enabled.
71
- *
72
- * @example
73
- * ```ts
74
- * map.keyboard.disableRotation();
75
- * ```
76
- */
77
- disableRotation(): void;
78
- /**
79
- * Enables the "keyboard pan/rotate" interaction.
80
- *
81
- * @example
82
- * ```ts
83
- * map.keyboard.enable();
84
- * map.keyboard.enableRotation();
85
- * ```
86
- */
87
- enableRotation(): void;
88
- }
@@ -1,197 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { TransformProvider } from "./transform-provider";
3
- const 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
- * @group Handlers
24
- */
25
- export class KeyboardHandler {
26
- /** @internal */
27
- constructor(map) {
28
- _defineProperty(this, "_tr", void 0);
29
- _defineProperty(this, "_enabled", void 0);
30
- _defineProperty(this, "_active", void 0);
31
- _defineProperty(this, "_panStep", void 0);
32
- _defineProperty(this, "_bearingStep", void 0);
33
- _defineProperty(this, "_pitchStep", void 0);
34
- _defineProperty(this, "_rotationDisabled", void 0);
35
- this._tr = new TransformProvider(map);
36
- const stepOptions = defaultOptions;
37
- this._panStep = stepOptions.panStep;
38
- this._bearingStep = stepOptions.bearingStep;
39
- this._pitchStep = stepOptions.pitchStep;
40
- this._rotationDisabled = false;
41
- }
42
- reset() {
43
- this._active = false;
44
- }
45
- keydown(e) {
46
- if (e.altKey || e.ctrlKey || e.metaKey) return;
47
- let zoomDir = 0;
48
- let bearingDir = 0;
49
- let pitchDir = 0;
50
- let xDir = 0;
51
- let yDir = 0;
52
- switch (e.keyCode) {
53
- case 61:
54
- case 107:
55
- case 171:
56
- case 187:
57
- zoomDir = 1;
58
- break;
59
- case 189:
60
- case 109:
61
- case 173:
62
- zoomDir = -1;
63
- break;
64
- case 37:
65
- if (e.shiftKey) {
66
- bearingDir = -1;
67
- } else {
68
- e.preventDefault();
69
- xDir = -1;
70
- }
71
- break;
72
- case 39:
73
- if (e.shiftKey) {
74
- bearingDir = 1;
75
- } else {
76
- e.preventDefault();
77
- xDir = 1;
78
- }
79
- break;
80
- case 38:
81
- if (e.shiftKey) {
82
- pitchDir = 1;
83
- } else {
84
- e.preventDefault();
85
- yDir = -1;
86
- }
87
- break;
88
- case 40:
89
- if (e.shiftKey) {
90
- pitchDir = -1;
91
- } else {
92
- e.preventDefault();
93
- yDir = 1;
94
- }
95
- break;
96
- default:
97
- return;
98
- }
99
- if (this._rotationDisabled) {
100
- bearingDir = 0;
101
- pitchDir = 0;
102
- }
103
- return {
104
- cameraAnimation: map => {
105
- const tr = this._tr;
106
- map.easeTo({
107
- duration: 300,
108
- easeId: 'keyboardHandler',
109
- easing: easeOut,
110
- zoom: zoomDir ? Math.round(tr.zoom) + zoomDir * (e.shiftKey ? 2 : 1) : tr.zoom,
111
- bearing: tr.bearing + bearingDir * this._bearingStep,
112
- pitch: tr.pitch + pitchDir * this._pitchStep,
113
- offset: [-xDir * this._panStep, -yDir * this._panStep],
114
- center: tr.center
115
- }, {
116
- originalEvent: e
117
- });
118
- }
119
- };
120
- }
121
-
122
- /**
123
- * Enables the "keyboard rotate and zoom" interaction.
124
- *
125
- * @example
126
- * ```ts
127
- * map.keyboard.enable();
128
- * ```
129
- */
130
- enable() {
131
- this._enabled = true;
132
- }
133
-
134
- /**
135
- * Disables the "keyboard rotate and zoom" interaction.
136
- *
137
- * @example
138
- * ```ts
139
- * map.keyboard.disable();
140
- * ```
141
- */
142
- disable() {
143
- this._enabled = false;
144
- this.reset();
145
- }
146
-
147
- /**
148
- * Returns a Boolean indicating whether the "keyboard rotate and zoom"
149
- * interaction is enabled.
150
- *
151
- * @returns `true` if the "keyboard rotate and zoom"
152
- * interaction is enabled.
153
- */
154
- isEnabled() {
155
- return this._enabled;
156
- }
157
-
158
- /**
159
- * Returns true if the handler is enabled and has detected the start of a
160
- * zoom/rotate gesture.
161
- *
162
- * @returns `true` if the handler is enabled and has detected the
163
- * start of a zoom/rotate gesture.
164
- */
165
- isActive() {
166
- return this._active;
167
- }
168
-
169
- /**
170
- * Disables the "keyboard pan/rotate" interaction, leaving the
171
- * "keyboard zoom" interaction enabled.
172
- *
173
- * @example
174
- * ```ts
175
- * map.keyboard.disableRotation();
176
- * ```
177
- */
178
- disableRotation() {
179
- this._rotationDisabled = true;
180
- }
181
-
182
- /**
183
- * Enables the "keyboard pan/rotate" interaction.
184
- *
185
- * @example
186
- * ```ts
187
- * map.keyboard.enable();
188
- * map.keyboard.enableRotation();
189
- * ```
190
- */
191
- enableRotation() {
192
- this._rotationDisabled = false;
193
- }
194
- }
195
- function easeOut(t) {
196
- return t * (2 - t);
197
- }
@@ -1,46 +0,0 @@
1
- /// <reference types="mapbox__point-geometry" />
2
- import type Point from '@mapbox/point-geometry';
3
- import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from '../events';
4
- import type { Handler } from '../handler_manager';
5
- import type { Map } from '../map';
6
- export declare class MapEventHandler implements Handler {
7
- _mousedownPos: Point;
8
- _clickTolerance: number;
9
- _map: Map;
10
- constructor(map: Map, options: {
11
- clickTolerance: number;
12
- });
13
- reset(): void;
14
- wheel(e: WheelEvent): {};
15
- mousedown(e: MouseEvent, point: Point): {};
16
- mouseup(e: MouseEvent): void;
17
- click(e: MouseEvent, point: Point): void;
18
- dblclick(e: MouseEvent): {};
19
- mouseover(e: MouseEvent): void;
20
- mouseout(e: MouseEvent): void;
21
- touchstart(e: TouchEvent): {};
22
- touchmove(e: TouchEvent): void;
23
- touchend(e: TouchEvent): void;
24
- touchcancel(e: TouchEvent): void;
25
- _firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent): {};
26
- isEnabled(): boolean;
27
- isActive(): boolean;
28
- enable(): void;
29
- disable(): void;
30
- }
31
- export declare class BlockableMapEventHandler {
32
- _map: Map;
33
- _delayContextMenu: boolean;
34
- _ignoreContextMenu: boolean;
35
- _contextMenuEvent: MouseEvent;
36
- constructor(map: Map);
37
- reset(): void;
38
- mousemove(e: MouseEvent): void;
39
- mousedown(): void;
40
- mouseup(): void;
41
- contextmenu(e: MouseEvent): void;
42
- isEnabled(): boolean;
43
- isActive(): boolean;
44
- enable(): void;
45
- disable(): void;
46
- }
@@ -1,131 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from "../events";
3
- export class MapEventHandler {
4
- constructor(map, options) {
5
- _defineProperty(this, "_mousedownPos", void 0);
6
- _defineProperty(this, "_clickTolerance", void 0);
7
- _defineProperty(this, "_map", void 0);
8
- this._map = map;
9
- this._clickTolerance = options.clickTolerance;
10
- }
11
- reset() {
12
- delete this._mousedownPos;
13
- }
14
- wheel(e) {
15
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
16
- // - ScrollZoom
17
- return this._firePreventable(new MapWheelEvent(e.type, this._map, e));
18
- }
19
- mousedown(e, point) {
20
- this._mousedownPos = point;
21
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
22
- // - MousePan
23
- // - MouseRotate
24
- // - MousePitch
25
- // - DblclickHandler
26
- return this._firePreventable(new MapMouseEvent(e.type, this._map, e));
27
- }
28
- mouseup(e) {
29
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
30
- }
31
- click(e, point) {
32
- if (this._mousedownPos && this._mousedownPos.dist(point) >= this._clickTolerance) return;
33
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
34
- }
35
- dblclick(e) {
36
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
37
- // - DblClickZoom
38
- return this._firePreventable(new MapMouseEvent(e.type, this._map, e));
39
- }
40
- mouseover(e) {
41
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
42
- }
43
- mouseout(e) {
44
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
45
- }
46
- touchstart(e) {
47
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
48
- // - TouchPan
49
- // - TouchZoom
50
- // - TouchRotate
51
- // - TouchPitch
52
- // - TapZoom
53
- // - SwipeZoom
54
- return this._firePreventable(new MapTouchEvent(e.type, this._map, e));
55
- }
56
- touchmove(e) {
57
- this._map.fire(new MapTouchEvent(e.type, this._map, e));
58
- }
59
- touchend(e) {
60
- this._map.fire(new MapTouchEvent(e.type, this._map, e));
61
- }
62
- touchcancel(e) {
63
- this._map.fire(new MapTouchEvent(e.type, this._map, e));
64
- }
65
- _firePreventable(mapEvent) {
66
- this._map.fire(mapEvent);
67
- if (mapEvent.defaultPrevented) {
68
- // returning an object marks the handler as active and resets other handlers
69
- return {};
70
- }
71
- }
72
- isEnabled() {
73
- return true;
74
- }
75
- isActive() {
76
- return false;
77
- }
78
- enable() {}
79
- disable() {}
80
- }
81
- export class BlockableMapEventHandler {
82
- constructor(map) {
83
- _defineProperty(this, "_map", void 0);
84
- _defineProperty(this, "_delayContextMenu", void 0);
85
- _defineProperty(this, "_ignoreContextMenu", void 0);
86
- _defineProperty(this, "_contextMenuEvent", void 0);
87
- this._map = map;
88
- }
89
- reset() {
90
- this._delayContextMenu = false;
91
- this._ignoreContextMenu = true;
92
- delete this._contextMenuEvent;
93
- }
94
- mousemove(e) {
95
- // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active
96
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
97
- }
98
- mousedown() {
99
- this._delayContextMenu = true;
100
- this._ignoreContextMenu = false;
101
- }
102
- mouseup() {
103
- this._delayContextMenu = false;
104
- if (this._contextMenuEvent) {
105
- this._map.fire(new MapMouseEvent('contextmenu', this._map, this._contextMenuEvent));
106
- delete this._contextMenuEvent;
107
- }
108
- }
109
- contextmenu(e) {
110
- if (this._delayContextMenu) {
111
- // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
112
- this._contextMenuEvent = e;
113
- } else if (!this._ignoreContextMenu) {
114
- // Windows: contextmenu fired on mouseup, so fire event now
115
- this._map.fire(new MapMouseEvent(e.type, this._map, e));
116
- }
117
-
118
- // prevent browser context menu when necessary
119
- if (this._map.listens('contextmenu')) {
120
- e.preventDefault();
121
- }
122
- }
123
- isEnabled() {
124
- return true;
125
- }
126
- isActive() {
127
- return false;
128
- }
129
- enable() {}
130
- disable() {}
131
- }
@@ -1,30 +0,0 @@
1
- import type { DragMoveHandler, DragPanResult, DragPitchResult, DragRotateResult } from './drag_handler';
2
- /**
3
- * `MousePanHandler` allows the user to pan the map by clicking and dragging
4
- */
5
- export interface MousePanHandler extends DragMoveHandler<DragPanResult, MouseEvent> {
6
- }
7
- /**
8
- * `MouseRotateHandler` allows the user to rotate the map by clicking and dragging
9
- */
10
- export interface MouseRotateHandler extends DragMoveHandler<DragRotateResult, MouseEvent> {
11
- }
12
- /**
13
- * `MousePitchHandler` allows the user to zoom the map by pitching
14
- */
15
- export interface MousePitchHandler extends DragMoveHandler<DragPitchResult, MouseEvent> {
16
- }
17
- export declare const generateMousePanHandler: ({ enable, clickTolerance, }: {
18
- clickTolerance: number;
19
- enable?: boolean;
20
- }) => MousePanHandler;
21
- export declare const generateMouseRotationHandler: ({ enable, clickTolerance, bearingDegreesPerPixelMoved, }: {
22
- clickTolerance: number;
23
- bearingDegreesPerPixelMoved?: number;
24
- enable?: boolean;
25
- }) => MouseRotateHandler;
26
- export declare const generateMousePitchHandler: ({ enable, clickTolerance, pitchDegreesPerPixelMoved, }: {
27
- clickTolerance: number;
28
- pitchDegreesPerPixelMoved?: number;
29
- enable?: boolean;
30
- }) => MousePitchHandler;
@@ -1,85 +0,0 @@
1
- import { DOM } from "../util/dom";
2
- import { DragHandler } from "./drag_handler";
3
- import { MouseMoveStateManager } from "./drag_move_state_manager";
4
-
5
- /**
6
- * `MousePanHandler` allows the user to pan the map by clicking and dragging
7
- */
8
-
9
- /**
10
- * `MouseRotateHandler` allows the user to rotate the map by clicking and dragging
11
- */
12
-
13
- /**
14
- * `MousePitchHandler` allows the user to zoom the map by pitching
15
- */
16
-
17
- const LEFT_BUTTON = 0;
18
- const RIGHT_BUTTON = 2;
19
- const assignEvents = handler => {
20
- handler.mousedown = handler.dragStart;
21
- handler.mousemoveWindow = handler.dragMove;
22
- handler.mouseup = handler.dragEnd;
23
- handler.contextmenu = e => {
24
- e.preventDefault();
25
- };
26
- };
27
- export const generateMousePanHandler = ({
28
- enable,
29
- clickTolerance
30
- }) => {
31
- const mouseMoveStateManager = new MouseMoveStateManager({
32
- checkCorrectEvent: e => DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey
33
- });
34
- return new DragHandler({
35
- clickTolerance,
36
- move: (lastPoint, point) => ({
37
- around: point,
38
- panDelta: point.sub(lastPoint)
39
- }),
40
- activateOnStart: true,
41
- moveStateManager: mouseMoveStateManager,
42
- enable,
43
- assignEvents
44
- });
45
- };
46
- export const generateMouseRotationHandler = ({
47
- enable,
48
- clickTolerance,
49
- bearingDegreesPerPixelMoved = 0.8
50
- }) => {
51
- const mouseMoveStateManager = new MouseMoveStateManager({
52
- checkCorrectEvent: e => DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey || DOM.mouseButton(e) === RIGHT_BUTTON
53
- });
54
- return new DragHandler({
55
- clickTolerance,
56
- move: (lastPoint, point) => ({
57
- bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved
58
- }),
59
- // prevent browser context menu when necessary; we don't allow it with rotation
60
- // because we can't discern rotation gesture start from contextmenu on Mac
61
- moveStateManager: mouseMoveStateManager,
62
- enable,
63
- assignEvents
64
- });
65
- };
66
- export const generateMousePitchHandler = ({
67
- enable,
68
- clickTolerance,
69
- pitchDegreesPerPixelMoved = -0.5
70
- }) => {
71
- const mouseMoveStateManager = new MouseMoveStateManager({
72
- checkCorrectEvent: e => DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey || DOM.mouseButton(e) === RIGHT_BUTTON
73
- });
74
- return new DragHandler({
75
- clickTolerance,
76
- move: (lastPoint, point) => ({
77
- pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved
78
- }),
79
- // prevent browser context menu when necessary; we don't allow it with rotation
80
- // because we can't discern rotation gesture start from contextmenu on Mac
81
- moveStateManager: mouseMoveStateManager,
82
- enable,
83
- assignEvents
84
- });
85
- };
@@ -1,15 +0,0 @@
1
- import type { DragMoveHandler, DragPitchResult, DragRotateResult } from './drag_handler';
2
- export interface OneFingerTouchRotateHandler extends DragMoveHandler<DragRotateResult, TouchEvent> {
3
- }
4
- export interface OneFingerTouchPitchHandler extends DragMoveHandler<DragPitchResult, TouchEvent> {
5
- }
6
- export declare const generateOneFingerTouchRotationHandler: ({ enable, clickTolerance, bearingDegreesPerPixelMoved, }: {
7
- clickTolerance: number;
8
- bearingDegreesPerPixelMoved?: number;
9
- enable?: boolean;
10
- }) => OneFingerTouchRotateHandler;
11
- export declare const generateOneFingerTouchPitchHandler: ({ enable, clickTolerance, pitchDegreesPerPixelMoved, }: {
12
- clickTolerance: number;
13
- pitchDegreesPerPixelMoved?: number;
14
- enable?: boolean;
15
- }) => OneFingerTouchPitchHandler;