@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,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.TwoFingersTouchZoomHandler = exports.TwoFingersTouchRotateHandler = exports.TwoFingersTouchPitchHandler = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _dom = require("../util/dom");
|
|
10
|
-
/**
|
|
11
|
-
* An options object sent to the enable function of some of the handlers
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
class TwoFingersTouchHandler {
|
|
19
|
-
/** @internal */
|
|
20
|
-
constructor() {
|
|
21
|
-
(0, _defineProperty2.default)(this, "_enabled", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "_active", void 0);
|
|
23
|
-
(0, _defineProperty2.default)(this, "_firstTwoTouches", void 0);
|
|
24
|
-
(0, _defineProperty2.default)(this, "_vector", void 0);
|
|
25
|
-
(0, _defineProperty2.default)(this, "_startVector", void 0);
|
|
26
|
-
(0, _defineProperty2.default)(this, "_aroundCenter", void 0);
|
|
27
|
-
this.reset();
|
|
28
|
-
}
|
|
29
|
-
reset() {
|
|
30
|
-
this._active = false;
|
|
31
|
-
delete this._firstTwoTouches;
|
|
32
|
-
}
|
|
33
|
-
touchstart(e, points, mapTouches) {
|
|
34
|
-
//log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);
|
|
35
|
-
if (this._firstTwoTouches || mapTouches.length < 2) return;
|
|
36
|
-
this._firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
37
|
-
|
|
38
|
-
// implemented by child classes
|
|
39
|
-
this._start([points[0], points[1]]);
|
|
40
|
-
}
|
|
41
|
-
touchmove(e, points, mapTouches) {
|
|
42
|
-
if (!this._firstTwoTouches) return;
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
const [idA, idB] = this._firstTwoTouches;
|
|
45
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
46
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
47
|
-
if (!a || !b) return;
|
|
48
|
-
const pinchAround = this._aroundCenter ? null : a.add(b).div(2);
|
|
49
|
-
|
|
50
|
-
// implemented by child classes
|
|
51
|
-
return this._move([a, b], pinchAround, e);
|
|
52
|
-
}
|
|
53
|
-
touchend(e, points, mapTouches) {
|
|
54
|
-
if (!this._firstTwoTouches) return;
|
|
55
|
-
const [idA, idB] = this._firstTwoTouches;
|
|
56
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
57
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
58
|
-
if (a && b) return;
|
|
59
|
-
if (this._active) _dom.DOM.suppressClick();
|
|
60
|
-
this.reset();
|
|
61
|
-
}
|
|
62
|
-
touchcancel() {
|
|
63
|
-
this.reset();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Enables the "drag to pitch" interaction.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* map.touchPitch.enable();
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
enable(options) {
|
|
75
|
-
this._enabled = true;
|
|
76
|
-
this._aroundCenter = !!options && options.around === 'center';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Disables the "drag to pitch" interaction.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* map.touchPitch.disable();
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
disable() {
|
|
88
|
-
this._enabled = false;
|
|
89
|
-
this.reset();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is enabled.
|
|
94
|
-
*
|
|
95
|
-
* @returns `true` if the "drag to pitch" interaction is enabled.
|
|
96
|
-
*/
|
|
97
|
-
isEnabled() {
|
|
98
|
-
return !!this._enabled;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used.
|
|
103
|
-
*
|
|
104
|
-
* @returns `true` if the "drag to pitch" interaction is active.
|
|
105
|
-
*/
|
|
106
|
-
isActive() {
|
|
107
|
-
return !!this._active;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function getTouchById(mapTouches, points, identifier) {
|
|
111
|
-
for (let i = 0; i < mapTouches.length; i++) {
|
|
112
|
-
if (mapTouches[i].identifier === identifier) return points[i];
|
|
113
|
-
}
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* ZOOM */
|
|
118
|
-
|
|
119
|
-
const ZOOM_THRESHOLD = 0.1;
|
|
120
|
-
function getZoomDelta(distance, lastDistance) {
|
|
121
|
-
return Math.log(distance / lastDistance) / Math.LN2;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers
|
|
126
|
-
*
|
|
127
|
-
* @group Handlers
|
|
128
|
-
*/
|
|
129
|
-
class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {
|
|
130
|
-
constructor(...args) {
|
|
131
|
-
super(...args);
|
|
132
|
-
(0, _defineProperty2.default)(this, "_distance", void 0);
|
|
133
|
-
(0, _defineProperty2.default)(this, "_startDistance", void 0);
|
|
134
|
-
}
|
|
135
|
-
reset() {
|
|
136
|
-
super.reset();
|
|
137
|
-
delete this._distance;
|
|
138
|
-
delete this._startDistance;
|
|
139
|
-
}
|
|
140
|
-
_start(points) {
|
|
141
|
-
this._startDistance = this._distance = points[0].dist(points[1]);
|
|
142
|
-
}
|
|
143
|
-
_move(points, pinchAround) {
|
|
144
|
-
const lastDistance = this._distance;
|
|
145
|
-
this._distance = points[0].dist(points[1]);
|
|
146
|
-
if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return;
|
|
147
|
-
this._active = true;
|
|
148
|
-
return {
|
|
149
|
-
zoomDelta: getZoomDelta(this._distance, lastDistance),
|
|
150
|
-
pinchAround
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/* ROTATE */
|
|
156
|
-
exports.TwoFingersTouchZoomHandler = TwoFingersTouchZoomHandler;
|
|
157
|
-
const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
158
|
-
|
|
159
|
-
function getBearingDelta(a, b) {
|
|
160
|
-
return a.angleWith(b) * 180 / Math.PI;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers
|
|
165
|
-
*
|
|
166
|
-
* @group Handlers
|
|
167
|
-
*/
|
|
168
|
-
class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {
|
|
169
|
-
constructor(...args) {
|
|
170
|
-
super(...args);
|
|
171
|
-
(0, _defineProperty2.default)(this, "_minDiameter", void 0);
|
|
172
|
-
}
|
|
173
|
-
reset() {
|
|
174
|
-
super.reset();
|
|
175
|
-
delete this._minDiameter;
|
|
176
|
-
delete this._startVector;
|
|
177
|
-
delete this._vector;
|
|
178
|
-
}
|
|
179
|
-
_start(points) {
|
|
180
|
-
this._startVector = this._vector = points[0].sub(points[1]);
|
|
181
|
-
this._minDiameter = points[0].dist(points[1]);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
185
|
-
_move(points, pinchAround, _e) {
|
|
186
|
-
const lastVector = this._vector;
|
|
187
|
-
this._vector = points[0].sub(points[1]);
|
|
188
|
-
if (!this._active && this._isBelowThreshold(this._vector)) return;
|
|
189
|
-
this._active = true;
|
|
190
|
-
return {
|
|
191
|
-
bearingDelta: getBearingDelta(this._vector, lastVector),
|
|
192
|
-
pinchAround
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
_isBelowThreshold(vector) {
|
|
196
|
-
/*
|
|
197
|
-
* The threshold before a rotation actually happens is configured in
|
|
198
|
-
* pixels along the circumference of the circle formed by the two fingers.
|
|
199
|
-
* This makes the threshold in degrees larger when the fingers are close
|
|
200
|
-
* together and smaller when the fingers are far apart.
|
|
201
|
-
*
|
|
202
|
-
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
203
|
-
* when pinching in and out.
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
this._minDiameter = Math.min(this._minDiameter, vector.mag());
|
|
207
|
-
const circumference = Math.PI * this._minDiameter;
|
|
208
|
-
const threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
209
|
-
const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector);
|
|
210
|
-
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/* PITCH */
|
|
215
|
-
exports.TwoFingersTouchRotateHandler = TwoFingersTouchRotateHandler;
|
|
216
|
-
function isVertical(vector) {
|
|
217
|
-
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
218
|
-
}
|
|
219
|
-
const ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.
|
|
223
|
-
*
|
|
224
|
-
* @group Handlers
|
|
225
|
-
*/
|
|
226
|
-
class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {
|
|
227
|
-
constructor(map) {
|
|
228
|
-
super();
|
|
229
|
-
(0, _defineProperty2.default)(this, "_valid", void 0);
|
|
230
|
-
(0, _defineProperty2.default)(this, "_firstMove", void 0);
|
|
231
|
-
(0, _defineProperty2.default)(this, "_lastPoints", void 0);
|
|
232
|
-
(0, _defineProperty2.default)(this, "_map", void 0);
|
|
233
|
-
(0, _defineProperty2.default)(this, "_currentTouchCount", 0);
|
|
234
|
-
this._map = map;
|
|
235
|
-
}
|
|
236
|
-
reset() {
|
|
237
|
-
super.reset();
|
|
238
|
-
this._valid = undefined;
|
|
239
|
-
delete this._firstMove;
|
|
240
|
-
delete this._lastPoints;
|
|
241
|
-
}
|
|
242
|
-
touchstart(e, points, mapTouches) {
|
|
243
|
-
super.touchstart(e, points, mapTouches);
|
|
244
|
-
this._currentTouchCount = mapTouches.length;
|
|
245
|
-
}
|
|
246
|
-
_start(points) {
|
|
247
|
-
this._lastPoints = points;
|
|
248
|
-
if (isVertical(points[0].sub(points[1]))) {
|
|
249
|
-
// fingers are more horizontal than vertical
|
|
250
|
-
this._valid = false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
_move(points, center, e) {
|
|
254
|
-
// If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register
|
|
255
|
-
if (this._map.cooperativeGestures.isEnabled() && this._currentTouchCount < 3) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
const vectorA = points[0].sub(this._lastPoints[0]);
|
|
259
|
-
const vectorB = points[1].sub(this._lastPoints[1]);
|
|
260
|
-
this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
261
|
-
if (!this._valid) return;
|
|
262
|
-
this._lastPoints = points;
|
|
263
|
-
this._active = true;
|
|
264
|
-
const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
265
|
-
const degreesPerPixelMoved = -0.5;
|
|
266
|
-
return {
|
|
267
|
-
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
271
|
-
if (this._valid !== undefined) return this._valid;
|
|
272
|
-
const threshold = 2;
|
|
273
|
-
const movedA = vectorA.mag() >= threshold;
|
|
274
|
-
const movedB = vectorB.mag() >= threshold;
|
|
275
|
-
|
|
276
|
-
// neither finger has moved a meaningful amount, wait
|
|
277
|
-
if (!movedA && !movedB) return;
|
|
278
|
-
|
|
279
|
-
// One finger has moved and the other has not.
|
|
280
|
-
// If enough time has passed, decide it is not a pitch.
|
|
281
|
-
if (!movedA || !movedB) {
|
|
282
|
-
if (this._firstMove === undefined) {
|
|
283
|
-
this._firstMove = timeStamp;
|
|
284
|
-
}
|
|
285
|
-
if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
286
|
-
// still waiting for a movement from the second finger
|
|
287
|
-
return undefined;
|
|
288
|
-
} else {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
293
|
-
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
exports.TwoFingersTouchPitchHandler = TwoFingersTouchPitchHandler;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DragPanOptions } from './handler/shim/drag_pan';
|
|
2
|
-
import type { Map } from './map';
|
|
3
|
-
export type InertiaOptions = {
|
|
4
|
-
linearity: number;
|
|
5
|
-
easing: (t: number) => number;
|
|
6
|
-
deceleration: number;
|
|
7
|
-
maxSpeed: number;
|
|
8
|
-
};
|
|
9
|
-
export declare class HandlerInertia {
|
|
10
|
-
_map: Map;
|
|
11
|
-
_inertiaBuffer: Array<{
|
|
12
|
-
time: number;
|
|
13
|
-
settings: any;
|
|
14
|
-
}>;
|
|
15
|
-
constructor(map: Map);
|
|
16
|
-
clear(): void;
|
|
17
|
-
record(settings: any): void;
|
|
18
|
-
_drainInertiaBuffer(): void;
|
|
19
|
-
_onMoveEnd(panInertiaOptions?: DragPanOptions | boolean): any;
|
|
20
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.HandlerInertia = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
10
|
-
var _browser = require("./util/browser");
|
|
11
|
-
var _util = require("./util/util");
|
|
12
|
-
const defaultInertiaOptions = {
|
|
13
|
-
linearity: 0.3,
|
|
14
|
-
easing: (0, _util.bezier)(0, 0, 0.3, 1)
|
|
15
|
-
};
|
|
16
|
-
const defaultPanInertiaOptions = (0, _util.extend)({
|
|
17
|
-
deceleration: 2500,
|
|
18
|
-
maxSpeed: 1400
|
|
19
|
-
}, defaultInertiaOptions);
|
|
20
|
-
const defaultZoomInertiaOptions = (0, _util.extend)({
|
|
21
|
-
deceleration: 20,
|
|
22
|
-
maxSpeed: 1400
|
|
23
|
-
}, defaultInertiaOptions);
|
|
24
|
-
const defaultBearingInertiaOptions = (0, _util.extend)({
|
|
25
|
-
deceleration: 1000,
|
|
26
|
-
maxSpeed: 360
|
|
27
|
-
}, defaultInertiaOptions);
|
|
28
|
-
const defaultPitchInertiaOptions = (0, _util.extend)({
|
|
29
|
-
deceleration: 1000,
|
|
30
|
-
maxSpeed: 90
|
|
31
|
-
}, defaultInertiaOptions);
|
|
32
|
-
class HandlerInertia {
|
|
33
|
-
constructor(map) {
|
|
34
|
-
(0, _defineProperty2.default)(this, "_map", void 0);
|
|
35
|
-
(0, _defineProperty2.default)(this, "_inertiaBuffer", void 0);
|
|
36
|
-
this._map = map;
|
|
37
|
-
this.clear();
|
|
38
|
-
}
|
|
39
|
-
clear() {
|
|
40
|
-
this._inertiaBuffer = [];
|
|
41
|
-
}
|
|
42
|
-
record(settings) {
|
|
43
|
-
this._drainInertiaBuffer();
|
|
44
|
-
this._inertiaBuffer.push({
|
|
45
|
-
time: _browser.browser.now(),
|
|
46
|
-
settings
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
_drainInertiaBuffer() {
|
|
50
|
-
const inertia = this._inertiaBuffer,
|
|
51
|
-
now = _browser.browser.now(),
|
|
52
|
-
cutoff = 160; //msec
|
|
53
|
-
|
|
54
|
-
while (inertia.length > 0 && now - inertia[0].time > cutoff) inertia.shift();
|
|
55
|
-
}
|
|
56
|
-
_onMoveEnd(panInertiaOptions) {
|
|
57
|
-
this._drainInertiaBuffer();
|
|
58
|
-
if (this._inertiaBuffer.length < 2) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const deltas = {
|
|
62
|
-
zoom: 0,
|
|
63
|
-
bearing: 0,
|
|
64
|
-
pitch: 0,
|
|
65
|
-
pan: new _pointGeometry.default(0, 0),
|
|
66
|
-
pinchAround: undefined,
|
|
67
|
-
around: undefined
|
|
68
|
-
};
|
|
69
|
-
for (const {
|
|
70
|
-
settings
|
|
71
|
-
} of this._inertiaBuffer) {
|
|
72
|
-
deltas.zoom += settings.zoomDelta || 0;
|
|
73
|
-
deltas.bearing += settings.bearingDelta || 0;
|
|
74
|
-
deltas.pitch += settings.pitchDelta || 0;
|
|
75
|
-
if (settings.panDelta) deltas.pan._add(settings.panDelta);
|
|
76
|
-
if (settings.around) deltas.around = settings.around;
|
|
77
|
-
if (settings.pinchAround) deltas.pinchAround = settings.pinchAround;
|
|
78
|
-
}
|
|
79
|
-
const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1];
|
|
80
|
-
const duration = lastEntry.time - this._inertiaBuffer[0].time;
|
|
81
|
-
const easeOptions = {};
|
|
82
|
-
if (deltas.pan.mag()) {
|
|
83
|
-
const result = calculateEasing(deltas.pan.mag(), duration, (0, _util.extend)({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
84
|
-
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
85
|
-
easeOptions.center = this._map.transform.center;
|
|
86
|
-
extendDuration(easeOptions, result);
|
|
87
|
-
}
|
|
88
|
-
if (deltas.zoom) {
|
|
89
|
-
const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
90
|
-
easeOptions.zoom = this._map.transform.zoom + result.amount;
|
|
91
|
-
extendDuration(easeOptions, result);
|
|
92
|
-
}
|
|
93
|
-
if (deltas.bearing) {
|
|
94
|
-
const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
95
|
-
easeOptions.bearing = this._map.transform.bearing + (0, _util.clamp)(result.amount, -179, 179);
|
|
96
|
-
extendDuration(easeOptions, result);
|
|
97
|
-
}
|
|
98
|
-
if (deltas.pitch) {
|
|
99
|
-
const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
100
|
-
easeOptions.pitch = this._map.transform.pitch + result.amount;
|
|
101
|
-
extendDuration(easeOptions, result);
|
|
102
|
-
}
|
|
103
|
-
if (easeOptions.zoom || easeOptions.bearing) {
|
|
104
|
-
const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
105
|
-
easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter();
|
|
106
|
-
}
|
|
107
|
-
this.clear();
|
|
108
|
-
return (0, _util.extend)(easeOptions, {
|
|
109
|
-
noMoveStart: true
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Unfortunately zoom, bearing, etc can't have different durations and easings so
|
|
115
|
-
// we need to choose one. We use the longest duration and it's corresponding easing.
|
|
116
|
-
exports.HandlerInertia = HandlerInertia;
|
|
117
|
-
function extendDuration(easeOptions, result) {
|
|
118
|
-
if (!easeOptions.duration || easeOptions.duration < result.duration) {
|
|
119
|
-
easeOptions.duration = result.duration;
|
|
120
|
-
easeOptions.easing = result.easing;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function calculateEasing(amount, inertiaDuration, inertiaOptions) {
|
|
124
|
-
const {
|
|
125
|
-
maxSpeed,
|
|
126
|
-
linearity,
|
|
127
|
-
deceleration
|
|
128
|
-
} = inertiaOptions;
|
|
129
|
-
const speed = (0, _util.clamp)(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
|
|
130
|
-
const duration = Math.abs(speed) / (deceleration * linearity);
|
|
131
|
-
return {
|
|
132
|
-
easing: inertiaOptions.easing,
|
|
133
|
-
duration: duration * 1000,
|
|
134
|
-
amount: speed * (duration / 2)
|
|
135
|
-
};
|
|
136
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/// <reference types="mapbox__point-geometry" />
|
|
2
|
-
import Point from '@mapbox/point-geometry';
|
|
3
|
-
import { HandlerInertia } from './handler_inertia';
|
|
4
|
-
import type { CompleteMapOptions, Map } from './map';
|
|
5
|
-
import { Event } from './util/evented';
|
|
6
|
-
/**
|
|
7
|
-
* Handlers interpret dom events and return camera changes that should be
|
|
8
|
-
* applied to the map (`HandlerResult`s). The camera changes are all deltas.
|
|
9
|
-
* The handler itself should have no knowledge of the map's current state.
|
|
10
|
-
* This makes it easier to merge multiple results and keeps handlers simpler.
|
|
11
|
-
* For example, if there is a mousedown and mousemove, the mousePan handler
|
|
12
|
-
* would return a `panDelta` on the mousemove.
|
|
13
|
-
*/
|
|
14
|
-
export interface Handler {
|
|
15
|
-
enable(): void;
|
|
16
|
-
disable(): void;
|
|
17
|
-
isEnabled(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* This is used to indicate if the handler is currently active or not.
|
|
20
|
-
* In case a handler is active, it will block other handlers from getting the relevant events.
|
|
21
|
-
* There is an allow list of handlers that can be active at the same time, which is configured when adding a handler.
|
|
22
|
-
*/
|
|
23
|
-
isActive(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* `reset` can be called by the manager at any time and must reset everything to it's original state
|
|
26
|
-
*/
|
|
27
|
-
reset(): void;
|
|
28
|
-
readonly touchstart?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
29
|
-
readonly touchmove?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
30
|
-
readonly touchmoveWindow?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
31
|
-
readonly touchend?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
32
|
-
readonly touchcancel?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
33
|
-
readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
34
|
-
readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
35
|
-
readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
36
|
-
readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
37
|
-
readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
38
|
-
readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
39
|
-
readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;
|
|
40
|
-
readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;
|
|
41
|
-
readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;
|
|
42
|
-
readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;
|
|
43
|
-
/**
|
|
44
|
-
* `renderFrame` is the only non-dom event. It is called during render
|
|
45
|
-
* frames and can be used to smooth camera changes (see scroll handler).
|
|
46
|
-
*/
|
|
47
|
-
readonly renderFrame?: () => HandlerResult | void;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* All handler methods that are called with events can optionally return a `HandlerResult`.
|
|
51
|
-
*/
|
|
52
|
-
export type HandlerResult = {
|
|
53
|
-
panDelta?: Point;
|
|
54
|
-
zoomDelta?: number;
|
|
55
|
-
bearingDelta?: number;
|
|
56
|
-
pitchDelta?: number;
|
|
57
|
-
/**
|
|
58
|
-
* the point to not move when changing the camera
|
|
59
|
-
*/
|
|
60
|
-
around?: Point | null;
|
|
61
|
-
/**
|
|
62
|
-
* same as above, except for pinch actions, which are given higher priority
|
|
63
|
-
*/
|
|
64
|
-
pinchAround?: Point | null;
|
|
65
|
-
/**
|
|
66
|
-
* A method that can fire a one-off easing by directly changing the map's camera.
|
|
67
|
-
*/
|
|
68
|
-
cameraAnimation?: (map: Map) => any;
|
|
69
|
-
/**
|
|
70
|
-
* The last three properties are needed by only one handler: scrollzoom.
|
|
71
|
-
* The DOM event to be used as the `originalEvent` on any camera change events.
|
|
72
|
-
*/
|
|
73
|
-
originalEvent?: Event;
|
|
74
|
-
/**
|
|
75
|
-
* Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).
|
|
76
|
-
*/
|
|
77
|
-
needsRenderFrame?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* The camera changes won't get recorded for inertial zooming.
|
|
80
|
-
*/
|
|
81
|
-
noInertia?: boolean;
|
|
82
|
-
};
|
|
83
|
-
export type EventInProgress = {
|
|
84
|
-
handlerName: string;
|
|
85
|
-
originalEvent: Event;
|
|
86
|
-
};
|
|
87
|
-
export type EventsInProgress = {
|
|
88
|
-
zoom?: EventInProgress;
|
|
89
|
-
pitch?: EventInProgress;
|
|
90
|
-
rotate?: EventInProgress;
|
|
91
|
-
drag?: EventInProgress;
|
|
92
|
-
};
|
|
93
|
-
export declare class HandlerManager {
|
|
94
|
-
_map: Map;
|
|
95
|
-
_el: HTMLElement;
|
|
96
|
-
_handlers: Array<{
|
|
97
|
-
handlerName: string;
|
|
98
|
-
handler: Handler;
|
|
99
|
-
allowed: Array<string>;
|
|
100
|
-
}>;
|
|
101
|
-
_eventsInProgress: EventsInProgress;
|
|
102
|
-
_frameId: number;
|
|
103
|
-
_inertia: HandlerInertia;
|
|
104
|
-
_bearingSnap: number;
|
|
105
|
-
_handlersById: {
|
|
106
|
-
[x: string]: Handler;
|
|
107
|
-
};
|
|
108
|
-
_updatingCamera: boolean;
|
|
109
|
-
_changes: Array<[HandlerResult, EventsInProgress, {
|
|
110
|
-
[handlerName: string]: Event;
|
|
111
|
-
}]>;
|
|
112
|
-
_zoom: {
|
|
113
|
-
handlerName: string;
|
|
114
|
-
};
|
|
115
|
-
_previousActiveHandlers: {
|
|
116
|
-
[x: string]: Handler;
|
|
117
|
-
};
|
|
118
|
-
_listeners: Array<[
|
|
119
|
-
Window | Document | HTMLElement,
|
|
120
|
-
string,
|
|
121
|
-
({
|
|
122
|
-
passive?: boolean;
|
|
123
|
-
capture?: boolean;
|
|
124
|
-
} | undefined)
|
|
125
|
-
]>;
|
|
126
|
-
constructor(map: Map, options: CompleteMapOptions);
|
|
127
|
-
destroy(): void;
|
|
128
|
-
_addDefaultHandlers(options: CompleteMapOptions): void;
|
|
129
|
-
_add(handlerName: string, handler: Handler, allowed?: Array<string>): void;
|
|
130
|
-
stop(allowEndAnimation: boolean): void;
|
|
131
|
-
isActive(): boolean;
|
|
132
|
-
isZooming(): boolean;
|
|
133
|
-
isRotating(): boolean;
|
|
134
|
-
isMoving(): boolean;
|
|
135
|
-
_blockedByActive(activeHandlers: {
|
|
136
|
-
[x: string]: Handler;
|
|
137
|
-
}, allowed: Array<string>, myName: string): boolean;
|
|
138
|
-
handleWindowEvent: (e: {
|
|
139
|
-
type: 'mousemove' | 'mouseup' | 'touchmove';
|
|
140
|
-
}) => void;
|
|
141
|
-
_getMapTouches(touches: TouchList): TouchList;
|
|
142
|
-
handleEvent: (e: Event, eventName?: keyof Handler) => void;
|
|
143
|
-
mergeHandlerResult(mergedHandlerResult: HandlerResult, eventsInProgress: EventsInProgress, handlerResult: HandlerResult, name: string, e?: UIEvent): void;
|
|
144
|
-
_applyChanges(): void;
|
|
145
|
-
_updateMapTransform(combinedResult: HandlerResult, combinedEventsInProgress: EventsInProgress, deactivatedHandlers: {
|
|
146
|
-
[handlerName: string]: Event;
|
|
147
|
-
}): void;
|
|
148
|
-
_fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {
|
|
149
|
-
[handlerName: string]: Event;
|
|
150
|
-
}, allowEndAnimation: boolean): void;
|
|
151
|
-
_fireEvent(type: string, e?: Event): void;
|
|
152
|
-
_requestFrame(): number;
|
|
153
|
-
_triggerRenderFrame(): void;
|
|
154
|
-
}
|