@antv/l7-map 2.9.33 → 2.9.34
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/lib/camera.js +766 -508
- package/lib/earthmap.js +389 -223
- package/lib/geo/edge_insets.js +117 -64
- package/lib/geo/lng_lat.js +86 -65
- package/lib/geo/lng_lat_bounds.js +162 -123
- package/lib/geo/mercator.js +91 -62
- package/lib/geo/point.js +234 -171
- package/lib/geo/simple.js +93 -61
- package/lib/geo/transform.js +982 -472
- package/lib/handler/IHandler.js +4 -16
- package/lib/handler/blockable_map_event.js +84 -63
- package/lib/handler/box_zoom.js +201 -123
- package/lib/handler/click_zoom.js +63 -55
- package/lib/handler/events/event.js +20 -35
- package/lib/handler/events/index.js +28 -35
- package/lib/handler/events/map_mouse_event.js +85 -42
- package/lib/handler/events/map_touch_event.js +116 -45
- package/lib/handler/events/map_wheel_event.js +70 -34
- package/lib/handler/events/render_event.js +50 -31
- package/lib/handler/handler_inertia.js +158 -114
- package/lib/handler/handler_manager.js +640 -381
- package/lib/handler/handler_util.js +11 -29
- package/lib/handler/keyboard.js +155 -114
- package/lib/handler/map_event.js +133 -84
- package/lib/handler/mouse/index.js +28 -35
- package/lib/handler/mouse/mouse_handler.js +126 -90
- package/lib/handler/mouse/mousepan_handler.js +64 -46
- package/lib/handler/mouse/mousepitch_hander.js +64 -44
- package/lib/handler/mouse/mouserotate_hander.js +64 -44
- package/lib/handler/mouse/util.js +22 -40
- package/lib/handler/scroll_zoom.js +318 -176
- package/lib/handler/shim/dblclick_zoom.js +76 -42
- package/lib/handler/shim/drag_pan.js +98 -48
- package/lib/handler/shim/drag_rotate.js +82 -43
- package/lib/handler/shim/touch_zoom_rotate.js +127 -59
- package/lib/handler/tap/single_tap_recognizer.js +113 -84
- package/lib/handler/tap/tap_drag_zoom.js +111 -93
- package/lib/handler/tap/tap_recognizer.js +72 -60
- package/lib/handler/tap/tap_zoom.js +113 -88
- package/lib/handler/touch/index.js +36 -38
- package/lib/handler/touch/touch_pan.js +126 -98
- package/lib/handler/touch/touch_pitch.js +108 -74
- package/lib/handler/touch/touch_rotate.js +93 -59
- package/lib/handler/touch/touch_zoom.js +71 -49
- package/lib/handler/touch/two_touch.js +129 -90
- package/lib/hash.js +149 -100
- package/lib/index.js +43 -20
- package/lib/interface.js +4 -16
- package/lib/map.js +420 -240
- package/lib/util.js +88 -69
- package/lib/utils/Aabb.js +134 -81
- package/lib/utils/dom.js +162 -88
- package/lib/utils/performance.js +46 -54
- package/lib/utils/primitives.js +53 -59
- package/lib/utils/task_queue.js +104 -61
- package/package.json +3 -3
|
@@ -1,74 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/handler/scroll_zoom.ts
|
|
23
|
-
var scroll_zoom_exports = {};
|
|
24
|
-
__export(scroll_zoom_exports, {
|
|
25
|
-
default: () => scroll_zoom_default
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _lng_lat = _interopRequireDefault(require("../geo/lng_lat"));
|
|
17
|
+
|
|
18
|
+
var _util = require("../util");
|
|
19
|
+
|
|
20
|
+
var _dom = _interopRequireDefault(require("../utils/dom"));
|
|
21
|
+
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
// deltaY value for mouse scroll wheel identification
|
|
24
|
+
var wheelZoomDelta = 4.000244140625; // These magic numbers control the rate of zoom. Trackpad events fire at a greater
|
|
25
|
+
// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick
|
|
26
|
+
|
|
32
27
|
var defaultZoomRate = 1 / 100;
|
|
33
|
-
var wheelZoomRate = 1 / 450;
|
|
28
|
+
var wheelZoomRate = 1 / 450; // upper bound on how much we scale the map in any single render frame; this
|
|
29
|
+
// is used to limit zoom rate in the case of very fast scrolling
|
|
30
|
+
|
|
34
31
|
var maxScalePerFrame = 2;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
var ScrollZoomHandler = /*#__PURE__*/function () {
|
|
37
|
+
// used for delayed-handling of a single wheel movement
|
|
38
|
+
// used to delay final '{move,zoom}end' events
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
function ScrollZoomHandler(map, handler) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
|
|
46
|
+
(0, _classCallCheck2.default)(this, ScrollZoomHandler);
|
|
47
|
+
(0, _defineProperty2.default)(this, "onScrollFrame", function () {
|
|
48
|
+
if (!_this.frameId) {
|
|
39
49
|
return;
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
|
|
52
|
+
_this.frameId = null;
|
|
53
|
+
|
|
54
|
+
if (!_this.isActive()) {
|
|
43
55
|
return;
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
|
|
58
|
+
var tr = _this.map.transform; // if we've had scroll events since the last render frame, consume the
|
|
59
|
+
// accumulated delta, and update the target zoom level accordingly
|
|
60
|
+
|
|
61
|
+
if (_this.delta !== 0) {
|
|
62
|
+
// For trackpad events and single mouse wheel ticks, use the default zoom rate
|
|
63
|
+
var zoomRate = _this.type === 'wheel' && Math.abs(_this.delta) > wheelZoomDelta ? _this.wheelZoomRate : _this.defaultZoomRate; // Scale by sigmoid of scroll wheel delta.
|
|
64
|
+
|
|
65
|
+
var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(_this.delta * zoomRate)));
|
|
66
|
+
|
|
67
|
+
if (_this.delta < 0 && scale !== 0) {
|
|
50
68
|
scale = 1 / scale;
|
|
51
69
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
|
|
71
|
+
var fromScale = typeof _this.targetZoom === 'number' ? tr.zoomScale(_this.targetZoom) : tr.scale;
|
|
72
|
+
_this.targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale))); // if this is a mouse wheel, refresh the starting zoom and easing
|
|
73
|
+
// function we're using to smooth out the zooming between wheel
|
|
74
|
+
// events
|
|
75
|
+
|
|
76
|
+
if (_this.type === 'wheel') {
|
|
77
|
+
_this.startZoom = tr.zoom;
|
|
78
|
+
_this.easing = _this.smoothOutEasing(200);
|
|
57
79
|
}
|
|
58
|
-
|
|
80
|
+
|
|
81
|
+
_this.delta = 0;
|
|
59
82
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
|
|
84
|
+
var targetZoom = typeof _this.targetZoom === 'number' ? _this.targetZoom : tr.zoom;
|
|
85
|
+
var startZoom = _this.startZoom;
|
|
86
|
+
var easing = _this.easing;
|
|
87
|
+
var finished = false;
|
|
88
|
+
var zoom;
|
|
89
|
+
|
|
90
|
+
if (_this.type === 'wheel' && startZoom && easing) {
|
|
91
|
+
var t = Math.min(((0, _util.now)() - _this.lastWheelEventTime) / 200, 1);
|
|
92
|
+
var k = easing(t);
|
|
93
|
+
zoom = (0, _util.interpolate)(startZoom, targetZoom, k);
|
|
94
|
+
|
|
69
95
|
if (t < 1) {
|
|
70
|
-
if (!
|
|
71
|
-
|
|
96
|
+
if (!_this.frameId) {
|
|
97
|
+
_this.frameId = true;
|
|
72
98
|
}
|
|
73
99
|
} else {
|
|
74
100
|
finished = true;
|
|
@@ -77,24 +103,32 @@ var ScrollZoomHandler = class {
|
|
|
77
103
|
zoom = targetZoom;
|
|
78
104
|
finished = true;
|
|
79
105
|
}
|
|
80
|
-
|
|
106
|
+
|
|
107
|
+
_this.active = true;
|
|
108
|
+
|
|
81
109
|
if (finished) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
_this.active = false; // @ts-ignore
|
|
111
|
+
|
|
112
|
+
_this.finishTimeout = setTimeout(function () {
|
|
113
|
+
_this.zooming = false;
|
|
114
|
+
|
|
115
|
+
_this.handler.triggerRenderFrame(); // @ts-ignore
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
delete _this.targetZoom; // @ts-ignore
|
|
119
|
+
|
|
120
|
+
delete _this.finishTimeout;
|
|
88
121
|
}, 200);
|
|
89
122
|
}
|
|
123
|
+
|
|
90
124
|
return {
|
|
91
125
|
noInertia: true,
|
|
92
126
|
needsRenderFrame: !finished,
|
|
93
127
|
zoomDelta: zoom - tr.zoom,
|
|
94
|
-
around:
|
|
95
|
-
originalEvent:
|
|
128
|
+
around: _this.aroundPoint,
|
|
129
|
+
originalEvent: _this.lastWheelEvent
|
|
96
130
|
};
|
|
97
|
-
};
|
|
131
|
+
});
|
|
98
132
|
this.map = map;
|
|
99
133
|
this.el = map.getCanvasContainer();
|
|
100
134
|
this.handler = handler;
|
|
@@ -102,124 +136,232 @@ var ScrollZoomHandler = class {
|
|
|
102
136
|
this.defaultZoomRate = defaultZoomRate;
|
|
103
137
|
this.wheelZoomRate = wheelZoomRate;
|
|
104
138
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return !!this.zooming;
|
|
119
|
-
}
|
|
120
|
-
enable(options) {
|
|
121
|
-
if (this.isEnabled()) {
|
|
122
|
-
return;
|
|
139
|
+
/**
|
|
140
|
+
* Set the zoom rate of a trackpad
|
|
141
|
+
* @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.
|
|
142
|
+
* @example
|
|
143
|
+
* // Speed up trackpad zoom
|
|
144
|
+
* map.scrollZoom.setZoomRate(1/25);
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
(0, _createClass2.default)(ScrollZoomHandler, [{
|
|
149
|
+
key: "setZoomRate",
|
|
150
|
+
value: function setZoomRate(zoomRate) {
|
|
151
|
+
this.defaultZoomRate = zoomRate;
|
|
123
152
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Set the zoom rate of a mouse wheel
|
|
155
|
+
* @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.
|
|
156
|
+
* @example
|
|
157
|
+
* // Slow down zoom of mouse wheel
|
|
158
|
+
* map.scrollZoom.setWheelZoomRate(1/600);
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
}, {
|
|
162
|
+
key: "setWheelZoomRate",
|
|
163
|
+
value: function setWheelZoomRate(zoomRate) {
|
|
164
|
+
this.wheelZoomRate = zoomRate;
|
|
130
165
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
|
|
168
|
+
*
|
|
169
|
+
* @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
}, {
|
|
173
|
+
key: "isEnabled",
|
|
174
|
+
value: function isEnabled() {
|
|
175
|
+
return !!this.enabled;
|
|
136
176
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
this.
|
|
147
|
-
this.lastValue = value;
|
|
148
|
-
this.timeout = setTimeout(this.onTimeout, 40, e);
|
|
149
|
-
} else if (!this.type) {
|
|
150
|
-
this.type = Math.abs(timeDelta * value) < 200 ? "trackpad" : "wheel";
|
|
151
|
-
if (this.timeout) {
|
|
152
|
-
clearTimeout(this.timeout);
|
|
153
|
-
this.timeout = null;
|
|
154
|
-
value += this.lastValue;
|
|
155
|
-
}
|
|
177
|
+
/*
|
|
178
|
+
* Active state is turned on and off with every scroll wheel event and is set back to false before the map
|
|
179
|
+
* render is called, so _active is not a good candidate for determining if a scroll zoom animation is in
|
|
180
|
+
* progress.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
}, {
|
|
184
|
+
key: "isActive",
|
|
185
|
+
value: function isActive() {
|
|
186
|
+
return !!this.active || this.finishTimeout !== undefined;
|
|
156
187
|
}
|
|
157
|
-
|
|
158
|
-
|
|
188
|
+
}, {
|
|
189
|
+
key: "isZooming",
|
|
190
|
+
value: function isZooming() {
|
|
191
|
+
return !!this.zooming;
|
|
159
192
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Enables the "scroll to zoom" interaction.
|
|
195
|
+
*
|
|
196
|
+
* @param {Object} [options] Options object.
|
|
197
|
+
* @param {string} [options.around] If "center" is passed, map will zoom around center of map
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* map.scrollZoom.enable();
|
|
201
|
+
* @example
|
|
202
|
+
* map.scrollZoom.enable({ around: 'center' })
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
}, {
|
|
206
|
+
key: "enable",
|
|
207
|
+
value: function enable(options) {
|
|
208
|
+
if (this.isEnabled()) {
|
|
209
|
+
return;
|
|
165
210
|
}
|
|
211
|
+
|
|
212
|
+
this.enabled = true;
|
|
213
|
+
this.aroundCenter = options && options.around === 'center';
|
|
166
214
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Disables the "scroll to zoom" interaction.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* map.scrollZoom.disable();
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
}, {
|
|
223
|
+
key: "disable",
|
|
224
|
+
value: function disable() {
|
|
225
|
+
if (!this.isEnabled()) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.enabled = false;
|
|
180
230
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
231
|
+
}, {
|
|
232
|
+
key: "wheel",
|
|
233
|
+
value: function wheel(e) {
|
|
234
|
+
if (!this.isEnabled()) {
|
|
235
|
+
return;
|
|
236
|
+
} // Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
var value = e.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;
|
|
240
|
+
var nowTime = (0, _util.now)();
|
|
241
|
+
var timeDelta = nowTime - (this.lastWheelEventTime || 0);
|
|
242
|
+
this.lastWheelEventTime = nowTime;
|
|
243
|
+
|
|
244
|
+
if (value !== 0 && value % wheelZoomDelta === 0) {
|
|
245
|
+
// This one is definitely a mouse wheel event.
|
|
246
|
+
this.type = 'wheel';
|
|
247
|
+
} else if (value !== 0 && Math.abs(value) < 4) {
|
|
248
|
+
// This one is definitely a trackpad event because it is so small.
|
|
249
|
+
this.type = 'trackpad';
|
|
250
|
+
} else if (timeDelta > 400) {
|
|
251
|
+
// This is likely a new scroll action.
|
|
252
|
+
this.type = null;
|
|
253
|
+
this.lastValue = value; // Start a timeout in case this was a singular event, and dely it by up to 40ms.
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
|
|
256
|
+
this.timeout = setTimeout(this.onTimeout, 40, e);
|
|
257
|
+
} else if (!this.type) {
|
|
258
|
+
// This is a repeating event, but we don't know the type of event just yet.
|
|
259
|
+
// If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.
|
|
260
|
+
this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel'; // Make sure our delayed event isn't fired again, because we accumulate
|
|
261
|
+
// the previous event (which was less than 40ms ago) into this event.
|
|
262
|
+
|
|
263
|
+
if (this.timeout) {
|
|
264
|
+
clearTimeout(this.timeout);
|
|
265
|
+
this.timeout = null;
|
|
266
|
+
value += this.lastValue;
|
|
267
|
+
}
|
|
268
|
+
} // Slow down zoom if shift key is held for more precise zooming
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if (e.shiftKey && value) {
|
|
272
|
+
value = value / 4;
|
|
273
|
+
} // Only fire the callback if we actually know what type of scrolling device the user uses.
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
if (this.type) {
|
|
277
|
+
this.lastWheelEvent = e;
|
|
278
|
+
this.delta -= value;
|
|
279
|
+
|
|
280
|
+
if (!this.active) {
|
|
281
|
+
this.start(e);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
e.preventDefault();
|
|
185
286
|
}
|
|
186
|
-
|
|
187
|
-
|
|
287
|
+
}, {
|
|
288
|
+
key: "renderFrame",
|
|
289
|
+
value: function renderFrame() {
|
|
290
|
+
return this.onScrollFrame();
|
|
188
291
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
292
|
+
}, {
|
|
293
|
+
key: "reset",
|
|
294
|
+
value: function reset() {
|
|
295
|
+
this.active = false;
|
|
192
296
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
297
|
+
}, {
|
|
298
|
+
key: "onTimeout",
|
|
299
|
+
value: function onTimeout(initialEvent) {
|
|
300
|
+
this.type = 'wheel';
|
|
301
|
+
this.delta -= this.lastValue;
|
|
302
|
+
|
|
303
|
+
if (!this.active && this.start) {
|
|
304
|
+
this.start(initialEvent);
|
|
305
|
+
}
|
|
196
306
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
307
|
+
}, {
|
|
308
|
+
key: "start",
|
|
309
|
+
value: function start(e) {
|
|
310
|
+
if (!this.delta) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (this.frameId) {
|
|
315
|
+
this.frameId = null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
this.active = true;
|
|
319
|
+
|
|
320
|
+
if (!this.isZooming()) {
|
|
321
|
+
this.zooming = true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (this.finishTimeout) {
|
|
325
|
+
clearTimeout(this.finishTimeout); // @ts-ignore
|
|
326
|
+
|
|
327
|
+
delete this.finishTimeout;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
var pos = _dom.default.mousePos(this.el, e);
|
|
331
|
+
|
|
332
|
+
this.around = _lng_lat.default.convert(this.aroundCenter ? this.map.getCenter() : this.map.unproject(pos));
|
|
333
|
+
this.aroundPoint = this.map.transform.locationPoint(this.around);
|
|
334
|
+
|
|
335
|
+
if (!this.frameId) {
|
|
336
|
+
this.frameId = true;
|
|
337
|
+
this.handler.triggerRenderFrame();
|
|
338
|
+
}
|
|
203
339
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
340
|
+
}, {
|
|
341
|
+
key: "smoothOutEasing",
|
|
342
|
+
value: function smoothOutEasing(duration) {
|
|
343
|
+
var easing = _util.ease;
|
|
344
|
+
|
|
345
|
+
if (this.prevEase) {
|
|
346
|
+
var preEase = this.prevEase;
|
|
347
|
+
var t = ((0, _util.now)() - preEase.start) / preEase.duration;
|
|
348
|
+
var speed = preEase.easing(t + 0.01) - preEase.easing(t); // Quick hack to make new bezier that is continuous with last
|
|
349
|
+
|
|
350
|
+
var x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
|
|
351
|
+
var y = Math.sqrt(0.27 * 0.27 - x * x);
|
|
352
|
+
easing = (0, _util.bezier)(x, y, 0.25, 1);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
this.prevEase = {
|
|
356
|
+
start: (0, _util.now)(),
|
|
357
|
+
duration: duration,
|
|
358
|
+
easing: easing
|
|
359
|
+
};
|
|
360
|
+
return easing;
|
|
214
361
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
var scroll_zoom_default = ScrollZoomHandler;
|
|
224
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
225
|
-
0 && (module.exports = {});
|
|
362
|
+
}]);
|
|
363
|
+
return ScrollZoomHandler;
|
|
364
|
+
}();
|
|
365
|
+
|
|
366
|
+
var _default = ScrollZoomHandler;
|
|
367
|
+
exports.default = _default;
|
|
@@ -1,46 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/handler/shim/dblclick_zoom.ts
|
|
20
|
-
var dblclick_zoom_exports = {};
|
|
21
|
-
__export(dblclick_zoom_exports, {
|
|
22
|
-
default: () => DoubleClickZoomHandler
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
23
7
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
|
|
16
|
+
* double clicking or double tapping.
|
|
17
|
+
*/
|
|
18
|
+
var DoubleClickZoomHandler = /*#__PURE__*/function () {
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function DoubleClickZoomHandler(clickZoom, TapZoom) {
|
|
23
|
+
(0, _classCallCheck2.default)(this, DoubleClickZoomHandler);
|
|
27
24
|
this.clickZoom = clickZoom;
|
|
28
25
|
this.tapZoom = TapZoom;
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Enables the "double click to zoom" interaction.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* map.doubleClickZoom.enable();
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
(0, _createClass2.default)(DoubleClickZoomHandler, [{
|
|
36
|
+
key: "enable",
|
|
37
|
+
value: function enable() {
|
|
38
|
+
this.clickZoom.enable();
|
|
39
|
+
this.tapZoom.enable();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Disables the "double click to zoom" interaction.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* map.doubleClickZoom.disable();
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
}, {
|
|
49
|
+
key: "disable",
|
|
50
|
+
value: function disable() {
|
|
51
|
+
this.clickZoom.disable();
|
|
52
|
+
this.tapZoom.disable();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
|
|
56
|
+
*
|
|
57
|
+
* @returns {boolean} `true` if the "double click to zoom" interaction is enabled.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
}, {
|
|
61
|
+
key: "isEnabled",
|
|
62
|
+
value: function isEnabled() {
|
|
63
|
+
return this.clickZoom.isEnabled() && this.tapZoom.isEnabled();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
|
|
67
|
+
*
|
|
68
|
+
* @returns {boolean} `true` if the "double click to zoom" interaction is active.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
}, {
|
|
72
|
+
key: "isActive",
|
|
73
|
+
value: function isActive() {
|
|
74
|
+
return this.clickZoom.isActive() || this.tapZoom.isActive();
|
|
75
|
+
}
|
|
76
|
+
}]);
|
|
77
|
+
return DoubleClickZoomHandler;
|
|
78
|
+
}();
|
|
79
|
+
|
|
80
|
+
exports.default = DoubleClickZoomHandler;
|