@antv/l7-map 2.25.6 → 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.
- package/package.json +2 -2
- package/es/index.d.ts +0 -5
- package/es/index.js +0 -4
- package/es/map/camera.d.ts +0 -690
- package/es/map/camera.js +0 -1138
- package/es/map/css/l7.css +0 -171
- package/es/map/events.d.ts +0 -384
- package/es/map/events.js +0 -231
- package/es/map/geo/edge_insets.d.ts +0 -97
- package/es/map/geo/edge_insets.js +0 -115
- package/es/map/geo/lng_lat.d.ts +0 -116
- package/es/map/geo/lng_lat.js +0 -159
- package/es/map/geo/lng_lat_bounds.d.ts +0 -217
- package/es/map/geo/lng_lat_bounds.js +0 -334
- package/es/map/geo/mercator_coordinate.d.ts +0 -113
- package/es/map/geo/mercator_coordinate.js +0 -142
- package/es/map/geo/transform.d.ts +0 -262
- package/es/map/geo/transform.js +0 -736
- package/es/map/handler/box_zoom.d.ts +0 -65
- package/es/map/handler/box_zoom.js +0 -145
- package/es/map/handler/click_zoom.d.ts +0 -24
- package/es/map/handler/click_zoom.js +0 -47
- package/es/map/handler/cooperative_gestures.d.ts +0 -40
- package/es/map/handler/cooperative_gestures.js +0 -94
- package/es/map/handler/drag_handler.d.ts +0 -88
- package/es/map/handler/drag_handler.js +0 -89
- package/es/map/handler/drag_move_state_manager.d.ts +0 -30
- package/es/map/handler/drag_move_state_manager.js +0 -94
- package/es/map/handler/handler_util.d.ts +0 -3
- package/es/map/handler/handler_util.js +0 -8
- package/es/map/handler/keyboard.d.ts +0 -88
- package/es/map/handler/keyboard.js +0 -197
- package/es/map/handler/map_event.d.ts +0 -46
- package/es/map/handler/map_event.js +0 -131
- package/es/map/handler/mouse.d.ts +0 -30
- package/es/map/handler/mouse.js +0 -85
- package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
- package/es/map/handler/one_finger_touch_drag.js +0 -39
- package/es/map/handler/scroll_zoom.d.ts +0 -102
- package/es/map/handler/scroll_zoom.js +0 -312
- package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
- package/es/map/handler/shim/dblclick_zoom.js +0 -60
- package/es/map/handler/shim/drag_pan.d.ts +0 -79
- package/es/map/handler/shim/drag_pan.js +0 -77
- package/es/map/handler/shim/drag_rotate.d.ts +0 -54
- package/es/map/handler/shim/drag_rotate.js +0 -66
- package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
- package/es/map/handler/shim/two_fingers_touch.js +0 -106
- package/es/map/handler/tap_drag_zoom.d.ts +0 -28
- package/es/map/handler/tap_drag_zoom.js +0 -92
- package/es/map/handler/tap_recognizer.d.ts +0 -35
- package/es/map/handler/tap_recognizer.js +0 -107
- package/es/map/handler/tap_zoom.d.ts +0 -28
- package/es/map/handler/tap_zoom.js +0 -87
- package/es/map/handler/touch_pan.d.ts +0 -40
- package/es/map/handler/touch_pan.js +0 -85
- package/es/map/handler/transform-provider.d.ts +0 -23
- package/es/map/handler/transform-provider.js +0 -35
- package/es/map/handler/two_fingers_touch.d.ts +0 -107
- package/es/map/handler/two_fingers_touch.js +0 -289
- package/es/map/handler_inertia.d.ts +0 -20
- package/es/map/handler_inertia.js +0 -128
- package/es/map/handler_manager.d.ts +0 -154
- package/es/map/handler_manager.js +0 -466
- package/es/map/map.d.ts +0 -637
- package/es/map/map.js +0 -984
- package/es/map/util/abort_error.d.ts +0 -15
- package/es/map/util/abort_error.js +0 -21
- package/es/map/util/browser.d.ts +0 -10
- package/es/map/util/browser.js +0 -30
- package/es/map/util/dom.d.ts +0 -30
- package/es/map/util/dom.js +0 -105
- package/es/map/util/evented.d.ts +0 -75
- package/es/map/util/evented.js +0 -158
- package/es/map/util/simpleMapCoord.d.ts +0 -31
- package/es/map/util/simpleMapCoord.js +0 -54
- package/es/map/util/task_queue.d.ts +0 -18
- package/es/map/util/task_queue.js +0 -54
- package/es/map/util/util.d.ts +0 -104
- package/es/map/util/util.js +0 -155
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -33
- package/lib/map/camera.d.ts +0 -690
- package/lib/map/camera.js +0 -1145
- package/lib/map/css/l7.css +0 -171
- package/lib/map/events.d.ts +0 -384
- package/lib/map/events.js +0 -240
- package/lib/map/geo/edge_insets.d.ts +0 -97
- package/lib/map/geo/edge_insets.js +0 -122
- package/lib/map/geo/lng_lat.d.ts +0 -116
- package/lib/map/geo/lng_lat.js +0 -166
- package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
- package/lib/map/geo/lng_lat_bounds.js +0 -341
- package/lib/map/geo/mercator_coordinate.d.ts +0 -113
- package/lib/map/geo/mercator_coordinate.js +0 -157
- package/lib/map/geo/transform.d.ts +0 -262
- package/lib/map/geo/transform.js +0 -744
- package/lib/map/handler/box_zoom.d.ts +0 -65
- package/lib/map/handler/box_zoom.js +0 -153
- package/lib/map/handler/click_zoom.d.ts +0 -24
- package/lib/map/handler/click_zoom.js +0 -54
- package/lib/map/handler/cooperative_gestures.d.ts +0 -40
- package/lib/map/handler/cooperative_gestures.js +0 -101
- package/lib/map/handler/drag_handler.d.ts +0 -88
- package/lib/map/handler/drag_handler.js +0 -97
- package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
- package/lib/map/handler/drag_move_state_manager.js +0 -103
- package/lib/map/handler/handler_util.d.ts +0 -3
- package/lib/map/handler/handler_util.js +0 -14
- package/lib/map/handler/keyboard.d.ts +0 -88
- package/lib/map/handler/keyboard.js +0 -205
- package/lib/map/handler/map_event.d.ts +0 -46
- package/lib/map/handler/map_event.js +0 -140
- package/lib/map/handler/mouse.d.ts +0 -30
- package/lib/map/handler/mouse.js +0 -93
- package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
- package/lib/map/handler/one_finger_touch_drag.js +0 -47
- package/lib/map/handler/scroll_zoom.d.ts +0 -102
- package/lib/map/handler/scroll_zoom.js +0 -320
- package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
- package/lib/map/handler/shim/dblclick_zoom.js +0 -68
- package/lib/map/handler/shim/drag_pan.d.ts +0 -79
- package/lib/map/handler/shim/drag_pan.js +0 -85
- package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
- package/lib/map/handler/shim/drag_rotate.js +0 -74
- package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
- package/lib/map/handler/shim/two_fingers_touch.js +0 -114
- package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
- package/lib/map/handler/tap_drag_zoom.js +0 -99
- package/lib/map/handler/tap_recognizer.d.ts +0 -35
- package/lib/map/handler/tap_recognizer.js +0 -116
- package/lib/map/handler/tap_zoom.d.ts +0 -28
- package/lib/map/handler/tap_zoom.js +0 -94
- package/lib/map/handler/touch_pan.d.ts +0 -40
- package/lib/map/handler/touch_pan.js +0 -92
- package/lib/map/handler/transform-provider.d.ts +0 -23
- package/lib/map/handler/transform-provider.js +0 -43
- package/lib/map/handler/two_fingers_touch.d.ts +0 -107
- package/lib/map/handler/two_fingers_touch.js +0 -296
- package/lib/map/handler_inertia.d.ts +0 -20
- package/lib/map/handler_inertia.js +0 -136
- package/lib/map/handler_manager.d.ts +0 -154
- package/lib/map/handler_manager.js +0 -474
- package/lib/map/map.d.ts +0 -637
- package/lib/map/map.js +0 -991
- package/lib/map/util/abort_error.d.ts +0 -15
- package/lib/map/util/abort_error.js +0 -29
- package/lib/map/util/browser.d.ts +0 -10
- package/lib/map/util/browser.js +0 -36
- package/lib/map/util/dom.d.ts +0 -30
- package/lib/map/util/dom.js +0 -113
- package/lib/map/util/evented.d.ts +0 -75
- package/lib/map/util/evented.js +0 -167
- package/lib/map/util/simpleMapCoord.d.ts +0 -31
- package/lib/map/util/simpleMapCoord.js +0 -62
- package/lib/map/util/task_queue.d.ts +0 -18
- package/lib/map/util/task_queue.js +0 -62
- package/lib/map/util/util.d.ts +0 -104
- package/lib/map/util/util.js +0 -171
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import Point from '@mapbox/point-geometry';
|
|
3
|
-
import { BoxZoomHandler } from "./handler/box_zoom";
|
|
4
|
-
import { ClickZoomHandler } from "./handler/click_zoom";
|
|
5
|
-
import { CooperativeGesturesHandler } from "./handler/cooperative_gestures";
|
|
6
|
-
import { KeyboardHandler } from "./handler/keyboard";
|
|
7
|
-
import { BlockableMapEventHandler, MapEventHandler } from "./handler/map_event";
|
|
8
|
-
import { generateMousePanHandler, generateMousePitchHandler, generateMouseRotationHandler } from "./handler/mouse";
|
|
9
|
-
import { ScrollZoomHandler } from "./handler/scroll_zoom";
|
|
10
|
-
import { DoubleClickZoomHandler } from "./handler/shim/dblclick_zoom";
|
|
11
|
-
import { DragPanHandler } from "./handler/shim/drag_pan";
|
|
12
|
-
import { DragRotateHandler } from "./handler/shim/drag_rotate";
|
|
13
|
-
import { TwoFingersTouchZoomRotateHandler } from "./handler/shim/two_fingers_touch";
|
|
14
|
-
import { TapDragZoomHandler } from "./handler/tap_drag_zoom";
|
|
15
|
-
import { TapZoomHandler } from "./handler/tap_zoom";
|
|
16
|
-
import { TouchPanHandler } from "./handler/touch_pan";
|
|
17
|
-
import { TwoFingersTouchPitchHandler, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler } from "./handler/two_fingers_touch";
|
|
18
|
-
import { HandlerInertia } from "./handler_inertia";
|
|
19
|
-
import { browser } from "./util/browser";
|
|
20
|
-
import { DOM } from "./util/dom";
|
|
21
|
-
import { Event } from "./util/evented";
|
|
22
|
-
import { extend } from "./util/util";
|
|
23
|
-
const isMoving = p => p.zoom || p.drag || p.pitch || p.rotate;
|
|
24
|
-
class RenderFrameEvent extends Event {
|
|
25
|
-
constructor(type, timeStamp) {
|
|
26
|
-
super(type);
|
|
27
|
-
_defineProperty(this, "type", 'renderFrame');
|
|
28
|
-
_defineProperty(this, "timeStamp", void 0);
|
|
29
|
-
this.timeStamp = timeStamp;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Handlers interpret dom events and return camera changes that should be
|
|
35
|
-
* applied to the map (`HandlerResult`s). The camera changes are all deltas.
|
|
36
|
-
* The handler itself should have no knowledge of the map's current state.
|
|
37
|
-
* This makes it easier to merge multiple results and keeps handlers simpler.
|
|
38
|
-
* For example, if there is a mousedown and mousemove, the mousePan handler
|
|
39
|
-
* would return a `panDelta` on the mousemove.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* All handler methods that are called with events can optionally return a `HandlerResult`.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
function hasChange(result) {
|
|
47
|
-
return result.panDelta && result.panDelta.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta;
|
|
48
|
-
}
|
|
49
|
-
export class HandlerManager {
|
|
50
|
-
constructor(map, options) {
|
|
51
|
-
_defineProperty(this, "_map", void 0);
|
|
52
|
-
_defineProperty(this, "_el", void 0);
|
|
53
|
-
_defineProperty(this, "_handlers", void 0);
|
|
54
|
-
_defineProperty(this, "_eventsInProgress", void 0);
|
|
55
|
-
_defineProperty(this, "_frameId", void 0);
|
|
56
|
-
_defineProperty(this, "_inertia", void 0);
|
|
57
|
-
_defineProperty(this, "_bearingSnap", void 0);
|
|
58
|
-
_defineProperty(this, "_handlersById", void 0);
|
|
59
|
-
_defineProperty(this, "_updatingCamera", void 0);
|
|
60
|
-
_defineProperty(this, "_changes", void 0);
|
|
61
|
-
_defineProperty(this, "_zoom", void 0);
|
|
62
|
-
_defineProperty(this, "_previousActiveHandlers", void 0);
|
|
63
|
-
_defineProperty(this, "_listeners", void 0);
|
|
64
|
-
_defineProperty(this, "handleWindowEvent", e => {
|
|
65
|
-
this.handleEvent(e, `${e.type}Window`);
|
|
66
|
-
});
|
|
67
|
-
_defineProperty(this, "handleEvent", (e, eventName) => {
|
|
68
|
-
if (e.type === 'blur') {
|
|
69
|
-
this.stop(true);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
this._updatingCamera = true;
|
|
73
|
-
const inputEvent = e.type === 'renderFrame' ? undefined : e;
|
|
74
|
-
|
|
75
|
-
/*
|
|
76
|
-
* We don't call e.preventDefault() for any events by default.
|
|
77
|
-
* Handlers are responsible for calling it where necessary.
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
const mergedHandlerResult = {
|
|
81
|
-
needsRenderFrame: false
|
|
82
|
-
};
|
|
83
|
-
const eventsInProgress = {};
|
|
84
|
-
const activeHandlers = {};
|
|
85
|
-
const eventTouches = e.touches;
|
|
86
|
-
const mapTouches = eventTouches ? this._getMapTouches(eventTouches) : undefined;
|
|
87
|
-
const points = mapTouches ? DOM.touchPos(this._map.getCanvasContainer(), mapTouches) : DOM.mousePos(this._map.getCanvasContainer(), e);
|
|
88
|
-
for (const {
|
|
89
|
-
handlerName,
|
|
90
|
-
handler,
|
|
91
|
-
allowed
|
|
92
|
-
} of this._handlers) {
|
|
93
|
-
if (!handler.isEnabled()) continue;
|
|
94
|
-
let data;
|
|
95
|
-
if (this._blockedByActive(activeHandlers, allowed, handlerName)) {
|
|
96
|
-
handler.reset();
|
|
97
|
-
} else {
|
|
98
|
-
if (handler[eventName || e.type]) {
|
|
99
|
-
data = handler[eventName || e.type](e, points, mapTouches);
|
|
100
|
-
this.mergeHandlerResult(mergedHandlerResult, eventsInProgress, data, handlerName, inputEvent);
|
|
101
|
-
if (data && data.needsRenderFrame) {
|
|
102
|
-
this._triggerRenderFrame();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (data || handler.isActive()) {
|
|
107
|
-
activeHandlers[handlerName] = handler;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const deactivatedHandlers = {};
|
|
111
|
-
for (const name in this._previousActiveHandlers) {
|
|
112
|
-
if (!activeHandlers[name]) {
|
|
113
|
-
deactivatedHandlers[name] = inputEvent;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
this._previousActiveHandlers = activeHandlers;
|
|
117
|
-
if (Object.keys(deactivatedHandlers).length || hasChange(mergedHandlerResult)) {
|
|
118
|
-
this._changes.push([mergedHandlerResult, eventsInProgress, deactivatedHandlers]);
|
|
119
|
-
this._triggerRenderFrame();
|
|
120
|
-
}
|
|
121
|
-
if (Object.keys(activeHandlers).length || hasChange(mergedHandlerResult)) {
|
|
122
|
-
this._map._stop(true);
|
|
123
|
-
}
|
|
124
|
-
this._updatingCamera = false;
|
|
125
|
-
const {
|
|
126
|
-
cameraAnimation
|
|
127
|
-
} = mergedHandlerResult;
|
|
128
|
-
if (cameraAnimation) {
|
|
129
|
-
this._inertia.clear();
|
|
130
|
-
this._fireEvents({}, {}, true);
|
|
131
|
-
this._changes = [];
|
|
132
|
-
cameraAnimation(this._map);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
this._map = map;
|
|
136
|
-
this._el = this._map.getCanvasContainer();
|
|
137
|
-
this._handlers = [];
|
|
138
|
-
this._handlersById = {};
|
|
139
|
-
this._changes = [];
|
|
140
|
-
this._inertia = new HandlerInertia(map);
|
|
141
|
-
this._bearingSnap = options.bearingSnap || 7;
|
|
142
|
-
this._previousActiveHandlers = {};
|
|
143
|
-
|
|
144
|
-
// Track whether map is currently moving, to compute start/move/end events
|
|
145
|
-
this._eventsInProgress = {};
|
|
146
|
-
this._addDefaultHandlers(options);
|
|
147
|
-
const el = this._el;
|
|
148
|
-
this._listeners = [
|
|
149
|
-
// This needs to be `passive: true` so that a double tap fires two
|
|
150
|
-
// pairs of touchstart/end events in iOS Safari 13. If this is set to
|
|
151
|
-
// `passive: false` then the second pair of events is only fired if
|
|
152
|
-
// preventDefault() is called on the first touchstart. Calling preventDefault()
|
|
153
|
-
// undesirably prevents click events.
|
|
154
|
-
[el, 'touchstart', {
|
|
155
|
-
passive: true
|
|
156
|
-
}],
|
|
157
|
-
// This needs to be `passive: false` so that scrolls and pinches can be
|
|
158
|
-
// prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.
|
|
159
|
-
[el, 'touchmove', {
|
|
160
|
-
passive: false
|
|
161
|
-
}], [el, 'touchend', undefined], [el, 'touchcancel', undefined], [el, 'mousedown', undefined], [el, 'mousemove', undefined], [el, 'mouseup', undefined],
|
|
162
|
-
// Bind window-level event listeners for move and up/end events. In the absence of
|
|
163
|
-
// the pointer capture API, which is not supported by all necessary platforms,
|
|
164
|
-
// window-level event listeners give us the best shot at capturing events that
|
|
165
|
-
// fall outside the map canvas element. Use `{capture: true}` for the move event
|
|
166
|
-
// to prevent map move events from being fired during a drag.
|
|
167
|
-
[document, 'mousemove', {
|
|
168
|
-
capture: true
|
|
169
|
-
}], [document, 'mouseup', undefined], [el, 'mouseover', undefined], [el, 'mouseout', undefined], [el, 'dblclick', undefined], [el, 'click', undefined], [el, 'keydown', {
|
|
170
|
-
capture: false
|
|
171
|
-
}], [el, 'keyup', undefined], [el, 'wheel', {
|
|
172
|
-
passive: false
|
|
173
|
-
}], [el, 'contextmenu', undefined], [window, 'blur', undefined]];
|
|
174
|
-
for (const [target, type, listenerOptions] of this._listeners) {
|
|
175
|
-
DOM.addEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
destroy() {
|
|
179
|
-
for (const [target, type, listenerOptions] of this._listeners) {
|
|
180
|
-
DOM.removeEventListener(target, type, target === document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
_addDefaultHandlers(options) {
|
|
184
|
-
const map = this._map;
|
|
185
|
-
const el = map.getCanvasContainer();
|
|
186
|
-
this._add('mapEvent', new MapEventHandler(map, options));
|
|
187
|
-
const boxZoom = map.boxZoom = new BoxZoomHandler(map, options);
|
|
188
|
-
this._add('boxZoom', boxZoom);
|
|
189
|
-
if (options.interactive && options.boxZoom) {
|
|
190
|
-
boxZoom.enable();
|
|
191
|
-
}
|
|
192
|
-
const cooperativeGestures = map.cooperativeGestures = new CooperativeGesturesHandler(map, options.cooperativeGestures);
|
|
193
|
-
this._add('cooperativeGestures', cooperativeGestures);
|
|
194
|
-
if (options.cooperativeGestures) {
|
|
195
|
-
cooperativeGestures.enable();
|
|
196
|
-
}
|
|
197
|
-
const tapZoom = new TapZoomHandler(map);
|
|
198
|
-
const clickZoom = new ClickZoomHandler(map);
|
|
199
|
-
map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);
|
|
200
|
-
this._add('tapZoom', tapZoom);
|
|
201
|
-
this._add('clickZoom', clickZoom);
|
|
202
|
-
if (options.interactive && options.doubleClickZoom) {
|
|
203
|
-
map.doubleClickZoom.enable();
|
|
204
|
-
}
|
|
205
|
-
const tapDragZoom = new TapDragZoomHandler();
|
|
206
|
-
this._add('tapDragZoom', tapDragZoom);
|
|
207
|
-
const touchPitch = map.touchPitch = new TwoFingersTouchPitchHandler(map);
|
|
208
|
-
this._add('touchPitch', touchPitch);
|
|
209
|
-
if (options.interactive && options.touchPitch) {
|
|
210
|
-
map.touchPitch.enable(options.touchPitch);
|
|
211
|
-
}
|
|
212
|
-
const mouseRotate = generateMouseRotationHandler(options);
|
|
213
|
-
const mousePitch = generateMousePitchHandler(options);
|
|
214
|
-
map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);
|
|
215
|
-
this._add('mouseRotate', mouseRotate, ['mousePitch']);
|
|
216
|
-
this._add('mousePitch', mousePitch, ['mouseRotate']);
|
|
217
|
-
if (options.interactive && options.dragRotate) {
|
|
218
|
-
map.dragRotate.enable();
|
|
219
|
-
}
|
|
220
|
-
const mousePan = generateMousePanHandler(options);
|
|
221
|
-
const touchPan = new TouchPanHandler(options, map);
|
|
222
|
-
map.dragPan = new DragPanHandler(el, mousePan, touchPan);
|
|
223
|
-
this._add('mousePan', mousePan);
|
|
224
|
-
this._add('touchPan', touchPan, ['touchZoom', 'touchRotate']);
|
|
225
|
-
if (options.interactive && options.dragPan) {
|
|
226
|
-
map.dragPan.enable(options.dragPan);
|
|
227
|
-
}
|
|
228
|
-
const touchRotate = new TwoFingersTouchRotateHandler();
|
|
229
|
-
const touchZoom = new TwoFingersTouchZoomHandler();
|
|
230
|
-
map.touchZoomRotate = new TwoFingersTouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);
|
|
231
|
-
this._add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);
|
|
232
|
-
this._add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);
|
|
233
|
-
if (options.interactive && options.touchZoomRotate) {
|
|
234
|
-
map.touchZoomRotate.enable(options.touchZoomRotate);
|
|
235
|
-
}
|
|
236
|
-
const scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, () => this._triggerRenderFrame());
|
|
237
|
-
this._add('scrollZoom', scrollZoom, ['mousePan']);
|
|
238
|
-
if (options.interactive && options.scrollZoom) {
|
|
239
|
-
map.scrollZoom.enable(options.scrollZoom);
|
|
240
|
-
}
|
|
241
|
-
const keyboard = map.keyboard = new KeyboardHandler(map);
|
|
242
|
-
this._add('keyboard', keyboard);
|
|
243
|
-
if (options.interactive && options.keyboard) {
|
|
244
|
-
map.keyboard.enable();
|
|
245
|
-
}
|
|
246
|
-
this._add('blockableMapEvent', new BlockableMapEventHandler(map));
|
|
247
|
-
}
|
|
248
|
-
_add(handlerName, handler, allowed) {
|
|
249
|
-
this._handlers.push({
|
|
250
|
-
handlerName,
|
|
251
|
-
handler,
|
|
252
|
-
allowed
|
|
253
|
-
});
|
|
254
|
-
this._handlersById[handlerName] = handler;
|
|
255
|
-
}
|
|
256
|
-
stop(allowEndAnimation) {
|
|
257
|
-
// do nothing if this method was triggered by a gesture update
|
|
258
|
-
if (this._updatingCamera) return;
|
|
259
|
-
for (const {
|
|
260
|
-
handler
|
|
261
|
-
} of this._handlers) {
|
|
262
|
-
handler.reset();
|
|
263
|
-
}
|
|
264
|
-
this._inertia.clear();
|
|
265
|
-
this._fireEvents({}, {}, allowEndAnimation);
|
|
266
|
-
this._changes = [];
|
|
267
|
-
}
|
|
268
|
-
isActive() {
|
|
269
|
-
for (const {
|
|
270
|
-
handler
|
|
271
|
-
} of this._handlers) {
|
|
272
|
-
if (handler.isActive()) return true;
|
|
273
|
-
}
|
|
274
|
-
return false;
|
|
275
|
-
}
|
|
276
|
-
isZooming() {
|
|
277
|
-
return !!this._eventsInProgress.zoom || this._map.scrollZoom.isZooming();
|
|
278
|
-
}
|
|
279
|
-
isRotating() {
|
|
280
|
-
return !!this._eventsInProgress.rotate;
|
|
281
|
-
}
|
|
282
|
-
isMoving() {
|
|
283
|
-
return Boolean(isMoving(this._eventsInProgress)) || this.isZooming();
|
|
284
|
-
}
|
|
285
|
-
_blockedByActive(activeHandlers, allowed, myName) {
|
|
286
|
-
for (const name in activeHandlers) {
|
|
287
|
-
if (name === myName) continue;
|
|
288
|
-
if (!allowed || allowed.indexOf(name) < 0) {
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
_getMapTouches(touches) {
|
|
295
|
-
const mapTouches = [];
|
|
296
|
-
for (const t of touches) {
|
|
297
|
-
const target = t.target;
|
|
298
|
-
if (this._el.contains(target)) {
|
|
299
|
-
mapTouches.push(t);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return mapTouches;
|
|
303
|
-
}
|
|
304
|
-
mergeHandlerResult(mergedHandlerResult, eventsInProgress, handlerResult, name, e) {
|
|
305
|
-
if (!handlerResult) return;
|
|
306
|
-
extend(mergedHandlerResult, handlerResult);
|
|
307
|
-
const eventData = {
|
|
308
|
-
handlerName: name,
|
|
309
|
-
originalEvent: handlerResult.originalEvent || e
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// track which handler changed which camera property
|
|
313
|
-
if (handlerResult.zoomDelta !== undefined) {
|
|
314
|
-
eventsInProgress.zoom = eventData;
|
|
315
|
-
}
|
|
316
|
-
if (handlerResult.panDelta !== undefined) {
|
|
317
|
-
eventsInProgress.drag = eventData;
|
|
318
|
-
}
|
|
319
|
-
if (handlerResult.pitchDelta !== undefined) {
|
|
320
|
-
eventsInProgress.pitch = eventData;
|
|
321
|
-
}
|
|
322
|
-
if (handlerResult.bearingDelta !== undefined) {
|
|
323
|
-
eventsInProgress.rotate = eventData;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
_applyChanges() {
|
|
327
|
-
const combined = {};
|
|
328
|
-
const combinedEventsInProgress = {};
|
|
329
|
-
const combinedDeactivatedHandlers = {};
|
|
330
|
-
for (const [change, eventsInProgress, deactivatedHandlers] of this._changes) {
|
|
331
|
-
if (change.panDelta) combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);
|
|
332
|
-
if (change.zoomDelta) combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;
|
|
333
|
-
if (change.bearingDelta) combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;
|
|
334
|
-
if (change.pitchDelta) combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;
|
|
335
|
-
if (change.around !== undefined) combined.around = change.around;
|
|
336
|
-
if (change.pinchAround !== undefined) combined.pinchAround = change.pinchAround;
|
|
337
|
-
if (change.noInertia) combined.noInertia = change.noInertia;
|
|
338
|
-
extend(combinedEventsInProgress, eventsInProgress);
|
|
339
|
-
extend(combinedDeactivatedHandlers, deactivatedHandlers);
|
|
340
|
-
}
|
|
341
|
-
this._updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);
|
|
342
|
-
this._changes = [];
|
|
343
|
-
}
|
|
344
|
-
_updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) {
|
|
345
|
-
const map = this._map;
|
|
346
|
-
const tr = map._getTransformForUpdate();
|
|
347
|
-
if (!hasChange(combinedResult)) {
|
|
348
|
-
return this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);
|
|
349
|
-
}
|
|
350
|
-
const {
|
|
351
|
-
panDelta,
|
|
352
|
-
zoomDelta,
|
|
353
|
-
bearingDelta,
|
|
354
|
-
pitchDelta,
|
|
355
|
-
pinchAround
|
|
356
|
-
} = combinedResult;
|
|
357
|
-
let {
|
|
358
|
-
around
|
|
359
|
-
} = combinedResult;
|
|
360
|
-
if (pinchAround !== undefined) {
|
|
361
|
-
around = pinchAround;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// stop any ongoing camera animations (easeTo, flyTo)
|
|
365
|
-
map._stop(true);
|
|
366
|
-
around = around || map.transform.centerPoint;
|
|
367
|
-
const loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);
|
|
368
|
-
if (bearingDelta) tr.bearing += bearingDelta;
|
|
369
|
-
if (pitchDelta) tr.pitch += pitchDelta;
|
|
370
|
-
if (zoomDelta) tr.zoom += zoomDelta;
|
|
371
|
-
tr.setLocationAtPoint(loc, around);
|
|
372
|
-
map._applyUpdatedTransform(tr);
|
|
373
|
-
this._map._update();
|
|
374
|
-
if (!combinedResult.noInertia) this._inertia.record(combinedResult);
|
|
375
|
-
this._fireEvents(combinedEventsInProgress, deactivatedHandlers, true);
|
|
376
|
-
}
|
|
377
|
-
_fireEvents(newEventsInProgress, deactivatedHandlers, allowEndAnimation) {
|
|
378
|
-
const wasMoving = isMoving(this._eventsInProgress);
|
|
379
|
-
const nowMoving = isMoving(newEventsInProgress);
|
|
380
|
-
const startEvents = {};
|
|
381
|
-
for (const eventName in newEventsInProgress) {
|
|
382
|
-
const {
|
|
383
|
-
originalEvent
|
|
384
|
-
} = newEventsInProgress[eventName];
|
|
385
|
-
if (!this._eventsInProgress[eventName]) {
|
|
386
|
-
startEvents[`${eventName}start`] = originalEvent;
|
|
387
|
-
}
|
|
388
|
-
this._eventsInProgress[eventName] = newEventsInProgress[eventName];
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// fire start events only after this._eventsInProgress has been updated
|
|
392
|
-
if (!wasMoving && nowMoving) {
|
|
393
|
-
this._fireEvent('movestart', nowMoving.originalEvent);
|
|
394
|
-
}
|
|
395
|
-
for (const name in startEvents) {
|
|
396
|
-
this._fireEvent(name, startEvents[name]);
|
|
397
|
-
}
|
|
398
|
-
if (nowMoving) {
|
|
399
|
-
this._fireEvent('move', nowMoving.originalEvent);
|
|
400
|
-
}
|
|
401
|
-
for (const eventName in newEventsInProgress) {
|
|
402
|
-
const {
|
|
403
|
-
originalEvent
|
|
404
|
-
} = newEventsInProgress[eventName];
|
|
405
|
-
this._fireEvent(eventName, originalEvent);
|
|
406
|
-
}
|
|
407
|
-
const endEvents = {};
|
|
408
|
-
let originalEndEvent;
|
|
409
|
-
for (const eventName in this._eventsInProgress) {
|
|
410
|
-
const {
|
|
411
|
-
handlerName,
|
|
412
|
-
originalEvent
|
|
413
|
-
} = this._eventsInProgress[eventName];
|
|
414
|
-
if (!this._handlersById[handlerName].isActive()) {
|
|
415
|
-
delete this._eventsInProgress[eventName];
|
|
416
|
-
originalEndEvent = deactivatedHandlers[handlerName] || originalEvent;
|
|
417
|
-
endEvents[`${eventName}end`] = originalEndEvent;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
for (const name in endEvents) {
|
|
421
|
-
this._fireEvent(name, endEvents[name]);
|
|
422
|
-
}
|
|
423
|
-
const stillMoving = isMoving(this._eventsInProgress);
|
|
424
|
-
const finishedMoving = (wasMoving || nowMoving) && !stillMoving;
|
|
425
|
-
if (allowEndAnimation && finishedMoving) {
|
|
426
|
-
this._updatingCamera = true;
|
|
427
|
-
const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);
|
|
428
|
-
const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;
|
|
429
|
-
if (inertialEase && (inertialEase.essential || !browser.prefersReducedMotion)) {
|
|
430
|
-
if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {
|
|
431
|
-
inertialEase.bearing = 0;
|
|
432
|
-
}
|
|
433
|
-
inertialEase.freezeElevation = true;
|
|
434
|
-
this._map.easeTo(inertialEase, {
|
|
435
|
-
originalEvent: originalEndEvent
|
|
436
|
-
});
|
|
437
|
-
} else {
|
|
438
|
-
this._map.fire(new Event('moveend', {
|
|
439
|
-
originalEvent: originalEndEvent
|
|
440
|
-
}));
|
|
441
|
-
if (shouldSnapToNorth(this._map.getBearing())) {
|
|
442
|
-
this._map.resetNorth();
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
this._updatingCamera = false;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
_fireEvent(type, e) {
|
|
449
|
-
this._map.fire(new Event(type, e ? {
|
|
450
|
-
originalEvent: e
|
|
451
|
-
} : {}));
|
|
452
|
-
}
|
|
453
|
-
_requestFrame() {
|
|
454
|
-
this._map.triggerRepaint();
|
|
455
|
-
return this._map._renderTaskQueue.add(timeStamp => {
|
|
456
|
-
delete this._frameId;
|
|
457
|
-
this.handleEvent(new RenderFrameEvent('renderFrame', timeStamp));
|
|
458
|
-
this._applyChanges();
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
_triggerRenderFrame() {
|
|
462
|
-
if (this._frameId === undefined) {
|
|
463
|
-
this._frameId = this._requestFrame();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|