@antv/l7-map 2.18.0 → 2.18.2
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.
- package/package.json +3 -3
- package/es/camera.d.ts +0 -85
- package/es/camera.js +0 -718
- package/es/css/l7.css +0 -98
- package/es/earthmap.d.ts +0 -66
- package/es/earthmap.js +0 -369
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/edge_insets.js +0 -108
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -73
- package/es/geo/lng_lat_bounds.d.ts +0 -24
- package/es/geo/lng_lat_bounds.js +0 -154
- package/es/geo/mercator.d.ts +0 -29
- package/es/geo/mercator.js +0 -84
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -224
- package/es/geo/simple.d.ts +0 -29
- package/es/geo/simple.js +0 -87
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -961
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -78
- package/es/handler/box_zoom.d.ts +0 -59
- package/es/handler/box_zoom.js +0 -180
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -54
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -11
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -4
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -64
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -95
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -50
- package/es/handler/events/render_event.d.ts +0 -5
- package/es/handler/events/render_event.js +0 -26
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_inertia.js +0 -157
- package/es/handler/handler_manager.d.ts +0 -61
- package/es/handler/handler_manager.js +0 -577
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/handler_util.js +0 -9
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -143
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -125
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -4
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -118
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -44
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -46
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -46
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -11
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -325
- package/es/handler/shim/dblclick_zoom.d.ts +0 -40
- package/es/handler/shim/dblclick_zoom.js +0 -67
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -84
- package/es/handler/shim/drag_rotate.d.ts +0 -46
- package/es/handler/shim/drag_rotate.js +0 -74
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -115
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -97
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -106
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -54
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -109
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -5
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -110
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -93
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -77
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -54
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -125
- package/es/hash.d.ts +0 -14
- package/es/hash.js +0 -134
- package/es/index.d.ts +0 -4
- package/es/index.js +0 -4
- package/es/interface.d.ts +0 -34
- package/es/interface.js +0 -1
- package/es/map.d.ts +0 -70
- package/es/map.js +0 -387
- package/es/util.d.ts +0 -25
- package/es/util.js +0 -88
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -112
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -140
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -62
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -47
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -89
- package/lib/camera.js +0 -724
- package/lib/css/l7.css +0 -98
- package/lib/earthmap.js +0 -376
- package/lib/geo/edge_insets.js +0 -114
- package/lib/geo/lng_lat.js +0 -81
- package/lib/geo/lng_lat_bounds.js +0 -161
- package/lib/geo/mercator.js +0 -100
- package/lib/geo/point.js +0 -231
- package/lib/geo/simple.js +0 -104
- package/lib/geo/transform.js +0 -971
- package/lib/handler/IHandler.js +0 -5
- package/lib/handler/blockable_map_event.js +0 -84
- package/lib/handler/box_zoom.js +0 -186
- package/lib/handler/click_zoom.js +0 -61
- package/lib/handler/events/event.js +0 -20
- package/lib/handler/events/index.js +0 -27
- package/lib/handler/events/map_mouse_event.js +0 -70
- package/lib/handler/events/map_touch_event.js +0 -100
- package/lib/handler/events/map_wheel_event.js +0 -57
- package/lib/handler/events/render_event.js +0 -33
- package/lib/handler/handler_inertia.js +0 -162
- package/lib/handler/handler_manager.js +0 -584
- package/lib/handler/handler_util.js +0 -15
- package/lib/handler/keyboard.js +0 -151
- package/lib/handler/map_event.js +0 -131
- package/lib/handler/mouse/index.js +0 -27
- package/lib/handler/mouse/mouse_handler.js +0 -124
- package/lib/handler/mouse/mousepan_handler.js +0 -49
- package/lib/handler/mouse/mousepitch_hander.js +0 -51
- package/lib/handler/mouse/mouserotate_hander.js +0 -51
- package/lib/handler/mouse/util.js +0 -22
- package/lib/handler/scroll_zoom.js +0 -333
- package/lib/handler/shim/dblclick_zoom.js +0 -74
- package/lib/handler/shim/drag_pan.js +0 -91
- package/lib/handler/shim/drag_rotate.js +0 -81
- package/lib/handler/shim/touch_zoom_rotate.js +0 -122
- package/lib/handler/tap/single_tap_recognizer.js +0 -106
- package/lib/handler/tap/tap_drag_zoom.js +0 -112
- package/lib/handler/tap/tap_recognizer.js +0 -63
- package/lib/handler/tap/tap_zoom.js +0 -115
- package/lib/handler/touch/index.js +0 -34
- package/lib/handler/touch/touch_pan.js +0 -117
- package/lib/handler/touch/touch_pitch.js +0 -98
- package/lib/handler/touch/touch_rotate.js +0 -82
- package/lib/handler/touch/touch_zoom.js +0 -59
- package/lib/handler/touch/two_touch.js +0 -131
- package/lib/hash.js +0 -143
- package/lib/index.js +0 -49
- package/lib/interface.js +0 -5
- package/lib/map.js +0 -394
- package/lib/util.js +0 -108
- package/lib/utils/Aabb.js +0 -119
- package/lib/utils/dom.js +0 -147
- package/lib/utils/performance.js +0 -70
- package/lib/utils/primitives.js +0 -54
- package/lib/utils/task_queue.js +0 -97
package/es/handler/keyboard.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
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;
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|
package/es/handler/map_event.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
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 };
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
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 };
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
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 };
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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 };
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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 };
|
package/es/handler/mouse/util.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|