@antv/l7-map 2.21.0 → 2.21.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/es/camera.js +595 -674
- package/es/earthmap.js +313 -276
- package/es/geo/edge_insets.js +57 -72
- package/es/geo/lng_lat.js +50 -64
- package/es/geo/lng_lat_bounds.js +101 -137
- package/es/geo/mercator.js +23 -35
- package/es/geo/point.js +150 -221
- package/es/geo/simple.js +22 -34
- package/es/geo/transform.js +839 -905
- package/es/handler/blockable_map_event.js +46 -66
- package/es/handler/box_zoom.js +125 -143
- package/es/handler/click_zoom.js +37 -51
- package/es/handler/events/event.js +11 -9
- package/es/handler/events/map_mouse_event.js +39 -54
- package/es/handler/events/map_touch_event.js +54 -73
- package/es/handler/events/map_wheel_event.js +22 -38
- package/es/handler/events/render_event.js +6 -23
- package/es/handler/handler_inertia.js +98 -113
- package/es/handler/handler_manager.js +349 -437
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +98 -110
- package/es/handler/map_event.js +81 -117
- package/es/handler/mouse/mouse_handler.js +81 -100
- package/es/handler/mouse/mousepan_handler.js +16 -39
- package/es/handler/mouse/mousepitch_hander.js +18 -40
- package/es/handler/mouse/mouserotate_hander.js +18 -40
- package/es/handler/mouse/util.js +7 -6
- package/es/handler/scroll_zoom.js +221 -231
- package/es/handler/shim/dblclick_zoom.js +36 -47
- package/es/handler/shim/drag_pan.js +41 -50
- package/es/handler/shim/drag_rotate.js +38 -48
- package/es/handler/shim/touch_zoom_rotate.js +68 -79
- package/es/handler/tap/single_tap_recognizer.js +60 -80
- package/es/handler/tap/tap_drag_zoom.js +72 -89
- package/es/handler/tap/tap_recognizer.js +37 -45
- package/es/handler/tap/tap_zoom.js +67 -95
- package/es/handler/touch/touch_pan.js +77 -96
- package/es/handler/touch/touch_pitch.js +61 -79
- package/es/handler/touch/touch_rotate.js +47 -67
- package/es/handler/touch/touch_zoom.js +29 -46
- package/es/handler/touch/two_touch.js +79 -104
- package/es/hash.js +75 -88
- package/es/map.js +318 -284
- package/es/util.js +18 -37
- package/es/utils/Aabb.js +60 -100
- package/es/utils/dom.js +32 -55
- package/es/utils/performance.js +25 -29
- package/es/utils/primitives.js +33 -43
- package/es/utils/task_queue.js +47 -76
- package/lib/camera.d.ts +86 -0
- package/lib/camera.js +597 -672
- package/lib/earthmap.d.ts +69 -0
- package/lib/earthmap.js +314 -276
- package/lib/geo/edge_insets.d.ts +54 -0
- package/lib/geo/edge_insets.js +58 -70
- package/lib/geo/lng_lat.d.ts +18 -0
- package/lib/geo/lng_lat.js +50 -62
- package/lib/geo/lng_lat_bounds.d.ts +25 -0
- package/lib/geo/lng_lat_bounds.js +102 -136
- package/lib/geo/mercator.d.ts +30 -0
- package/lib/geo/mercator.js +26 -37
- package/lib/geo/point.d.ts +40 -0
- package/lib/geo/point.js +151 -220
- package/lib/geo/simple.d.ts +30 -0
- package/lib/geo/simple.js +25 -36
- package/lib/geo/transform.d.ts +198 -0
- package/lib/geo/transform.js +844 -907
- package/lib/handler/IHandler.d.ts +34 -0
- package/lib/handler/blockable_map_event.d.ts +17 -0
- package/lib/handler/blockable_map_event.js +48 -65
- package/lib/handler/box_zoom.d.ts +59 -0
- package/lib/handler/box_zoom.js +126 -143
- package/lib/handler/click_zoom.d.ts +16 -0
- package/lib/handler/click_zoom.js +38 -50
- package/lib/handler/events/event.d.ts +4 -0
- package/lib/handler/events/event.js +12 -9
- package/lib/handler/events/index.d.ts +4 -0
- package/lib/handler/events/index.js +3 -3
- package/lib/handler/events/map_mouse_event.d.ts +34 -0
- package/lib/handler/events/map_mouse_event.js +41 -52
- package/lib/handler/events/map_touch_event.d.ts +57 -0
- package/lib/handler/events/map_touch_event.js +56 -71
- package/lib/handler/events/map_wheel_event.d.ts +33 -0
- package/lib/handler/events/map_wheel_event.js +23 -37
- package/lib/handler/events/render_event.d.ts +5 -0
- package/lib/handler/events/render_event.js +7 -22
- package/lib/handler/handler_inertia.d.ts +23 -0
- package/lib/handler/handler_inertia.js +102 -112
- package/lib/handler/handler_manager.d.ts +61 -0
- package/lib/handler/handler_manager.js +351 -437
- package/lib/handler/handler_util.d.ts +4 -0
- package/lib/handler/handler_util.js +2 -2
- package/lib/handler/keyboard.d.ts +36 -0
- package/lib/handler/keyboard.js +98 -110
- package/lib/handler/map_event.d.ts +29 -0
- package/lib/handler/map_event.js +83 -116
- package/lib/handler/mouse/index.d.ts +4 -0
- package/lib/handler/mouse/index.js +3 -3
- package/lib/handler/mouse/mouse_handler.d.ts +22 -0
- package/lib/handler/mouse/mouse_handler.js +83 -99
- package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
- package/lib/handler/mouse/mousepan_handler.js +19 -38
- package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/lib/handler/mouse/mousepitch_hander.js +21 -39
- package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/lib/handler/mouse/mouserotate_hander.js +21 -39
- package/lib/handler/mouse/util.d.ts +6 -0
- package/lib/handler/mouse/util.js +7 -7
- package/lib/handler/scroll_zoom.d.ts +93 -0
- package/lib/handler/scroll_zoom.js +221 -231
- package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
- package/lib/handler/shim/dblclick_zoom.js +37 -46
- package/lib/handler/shim/drag_pan.d.ts +61 -0
- package/lib/handler/shim/drag_pan.js +42 -49
- package/lib/handler/shim/drag_rotate.d.ts +46 -0
- package/lib/handler/shim/drag_rotate.js +39 -47
- package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/lib/handler/shim/touch_zoom_rotate.js +69 -78
- package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/lib/handler/tap/single_tap_recognizer.js +63 -79
- package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_drag_zoom.js +74 -88
- package/lib/handler/tap/tap_recognizer.d.ts +17 -0
- package/lib/handler/tap/tap_recognizer.js +41 -47
- package/lib/handler/tap/tap_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_zoom.js +69 -94
- package/lib/handler/touch/index.d.ts +5 -0
- package/lib/handler/touch/index.js +4 -4
- package/lib/handler/touch/touch_pan.d.ts +30 -0
- package/lib/handler/touch/touch_pan.js +79 -95
- package/lib/handler/touch/touch_pitch.d.ts +13 -0
- package/lib/handler/touch/touch_pitch.js +64 -78
- package/lib/handler/touch/touch_rotate.d.ts +12 -0
- package/lib/handler/touch/touch_rotate.js +50 -66
- package/lib/handler/touch/touch_zoom.d.ts +12 -0
- package/lib/handler/touch/touch_zoom.js +32 -45
- package/lib/handler/touch/two_touch.d.ts +23 -0
- package/lib/handler/touch/two_touch.js +81 -103
- package/lib/hash.d.ts +14 -0
- package/lib/hash.js +75 -88
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -4
- package/lib/interface.d.ts +34 -0
- package/lib/map.d.ts +70 -0
- package/lib/map.js +319 -284
- package/lib/util.d.ts +25 -0
- package/lib/util.js +20 -36
- package/lib/utils/Aabb.d.ts +12 -0
- package/lib/utils/Aabb.js +61 -99
- package/lib/utils/dom.d.ts +4 -0
- package/lib/utils/dom.js +34 -55
- package/lib/utils/performance.d.ts +17 -0
- package/lib/utils/performance.js +25 -29
- package/lib/utils/primitives.d.ts +6 -0
- package/lib/utils/primitives.js +34 -42
- package/lib/utils/task_queue.d.ts +13 -0
- package/lib/utils/task_queue.js +47 -76
- package/package.json +25 -32
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
/**
|
|
11
10
|
* The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
|
|
12
11
|
* pinching on a touchscreen.
|
|
@@ -14,12 +13,17 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
14
13
|
* They can zoom with one finger by double tapping and dragging. On the second tap,
|
|
15
14
|
* hold the finger down and drag up or down to zoom in or out.
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
class TouchZoomRotateHandler {
|
|
18
17
|
/**
|
|
19
18
|
* @private
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
(0,
|
|
20
|
+
constructor(el, touchZoom, touchRotate, tapDragZoom) {
|
|
21
|
+
(0, _defineProperty2.default)(this, "el", void 0);
|
|
22
|
+
(0, _defineProperty2.default)(this, "touchZoom", void 0);
|
|
23
|
+
(0, _defineProperty2.default)(this, "touchRotate", void 0);
|
|
24
|
+
(0, _defineProperty2.default)(this, "tapDragZoom", void 0);
|
|
25
|
+
(0, _defineProperty2.default)(this, "rotationDisabled", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
23
27
|
this.el = el;
|
|
24
28
|
this.touchZoom = touchZoom;
|
|
25
29
|
this.touchRotate = touchRotate;
|
|
@@ -39,83 +43,70 @@ var TouchZoomRotateHandler = exports.default = /*#__PURE__*/function () {
|
|
|
39
43
|
* @example
|
|
40
44
|
* map.touchZoomRotate.enable({ around: 'center' });
|
|
41
45
|
*/
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
if (!this.rotationDisabled) {
|
|
47
|
-
this.touchRotate.enable(options);
|
|
48
|
-
}
|
|
49
|
-
this.tapDragZoom.enable();
|
|
50
|
-
this.el.classList.add('l7-touch-zoom-rotate');
|
|
46
|
+
enable(options) {
|
|
47
|
+
this.touchZoom.enable(options);
|
|
48
|
+
if (!this.rotationDisabled) {
|
|
49
|
+
this.touchRotate.enable(options);
|
|
51
50
|
}
|
|
51
|
+
this.tapDragZoom.enable();
|
|
52
|
+
this.el.classList.add('l7-touch-zoom-rotate');
|
|
53
|
+
}
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
66
|
-
}
|
|
55
|
+
/**
|
|
56
|
+
* Disables the "pinch to rotate and zoom" interaction.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* map.touchZoomRotate.disable();
|
|
60
|
+
*/
|
|
61
|
+
disable() {
|
|
62
|
+
this.touchZoom.disable();
|
|
63
|
+
this.touchRotate.disable();
|
|
64
|
+
this.tapDragZoom.disable();
|
|
65
|
+
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
77
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
|
|
70
|
+
*
|
|
71
|
+
* @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
|
|
72
|
+
*/
|
|
73
|
+
isEnabled() {
|
|
74
|
+
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
75
|
+
}
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
88
|
-
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
|
|
79
|
+
*
|
|
80
|
+
* @returns {boolean} //eslint-disable-line
|
|
81
|
+
*/
|
|
82
|
+
isActive() {
|
|
83
|
+
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
84
|
+
}
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.touchRotate.disable();
|
|
102
|
-
}
|
|
86
|
+
/**
|
|
87
|
+
* Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
|
|
88
|
+
* interaction enabled.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* map.touchZoomRotate.disableRotation();
|
|
92
|
+
*/
|
|
93
|
+
disableRotation() {
|
|
94
|
+
this.rotationDisabled = true;
|
|
95
|
+
this.touchRotate.disable();
|
|
96
|
+
}
|
|
103
97
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
if (this.touchZoom.isEnabled()) {
|
|
116
|
-
this.touchRotate.enable();
|
|
117
|
-
}
|
|
98
|
+
/**
|
|
99
|
+
* Enables the "pinch to rotate" interaction.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* map.touchZoomRotate.enable();
|
|
103
|
+
* map.touchZoomRotate.enableRotation();
|
|
104
|
+
*/
|
|
105
|
+
enableRotation() {
|
|
106
|
+
this.rotationDisabled = false;
|
|
107
|
+
if (this.touchZoom.isEnabled()) {
|
|
108
|
+
this.touchRotate.enable();
|
|
118
109
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.default = TouchZoomRotateHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Point from '../../geo/point';
|
|
2
|
+
export declare const MAX_TAP_INTERVAL = 500;
|
|
3
|
+
export declare const MAX_TOUCH_TIME = 500;
|
|
4
|
+
export declare const MAX_DIST = 30;
|
|
5
|
+
export default class SingleTapRecognizer {
|
|
6
|
+
numTouches: number;
|
|
7
|
+
centroid: Point;
|
|
8
|
+
startTime: number;
|
|
9
|
+
aborted: boolean;
|
|
10
|
+
touches: {
|
|
11
|
+
[key: string]: Point;
|
|
12
|
+
};
|
|
13
|
+
constructor(options: {
|
|
14
|
+
numTouches: number;
|
|
15
|
+
});
|
|
16
|
+
reset(): void;
|
|
17
|
+
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
18
|
+
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
19
|
+
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
|
|
20
|
+
}
|
|
@@ -5,98 +5,82 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.MAX_TOUCH_TIME = exports.MAX_TAP_INTERVAL = exports.MAX_DIST = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _point = _interopRequireDefault(require("../../geo/point"));
|
|
11
10
|
var _handler_util = require("../handler_util");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } // @ts-ignore
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
|
|
15
13
|
function getCentroid(points) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
21
|
-
var point = _step.value;
|
|
22
|
-
sum._add(point);
|
|
23
|
-
}
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
} catch (err) {
|
|
26
|
-
_iterator.e(err);
|
|
27
|
-
} finally {
|
|
28
|
-
_iterator.f();
|
|
14
|
+
const sum = new _point.default(0, 0);
|
|
15
|
+
for (const point of points) {
|
|
16
|
+
sum._add(point);
|
|
29
17
|
}
|
|
18
|
+
// @ts-ignore
|
|
30
19
|
return sum.div(points.length);
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(0,
|
|
21
|
+
const MAX_TAP_INTERVAL = exports.MAX_TAP_INTERVAL = 500;
|
|
22
|
+
const MAX_TOUCH_TIME = exports.MAX_TOUCH_TIME = 500;
|
|
23
|
+
const MAX_DIST = exports.MAX_DIST = 30;
|
|
24
|
+
class SingleTapRecognizer {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
(0, _defineProperty2.default)(this, "numTouches", void 0);
|
|
27
|
+
(0, _defineProperty2.default)(this, "centroid", void 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "startTime", void 0);
|
|
29
|
+
(0, _defineProperty2.default)(this, "aborted", void 0);
|
|
30
|
+
(0, _defineProperty2.default)(this, "touches", void 0);
|
|
38
31
|
this.reset();
|
|
39
32
|
this.numTouches = options.numTouches;
|
|
40
33
|
}
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
reset() {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
delete this.centroid;
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
delete this.startTime;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
delete this.touches;
|
|
41
|
+
this.aborted = false;
|
|
42
|
+
}
|
|
43
|
+
touchstart(e, points, mapTouches) {
|
|
44
|
+
if (this.centroid || mapTouches.length > this.numTouches) {
|
|
45
|
+
this.aborted = true;
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
value: function touchstart(e, points, mapTouches) {
|
|
55
|
-
if (this.centroid || mapTouches.length > this.numTouches) {
|
|
56
|
-
this.aborted = true;
|
|
57
|
-
}
|
|
58
|
-
if (this.aborted) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (this.startTime === undefined) {
|
|
62
|
-
this.startTime = e.timeStamp;
|
|
63
|
-
}
|
|
64
|
-
if (mapTouches.length === this.numTouches) {
|
|
65
|
-
this.centroid = getCentroid(points);
|
|
66
|
-
this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
67
|
-
}
|
|
47
|
+
if (this.aborted) {
|
|
48
|
+
return;
|
|
68
49
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
if (this.startTime === undefined) {
|
|
51
|
+
this.startTime = e.timeStamp;
|
|
52
|
+
}
|
|
53
|
+
if (mapTouches.length === this.numTouches) {
|
|
54
|
+
this.centroid = getCentroid(points);
|
|
55
|
+
this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
touchmove(e, points, mapTouches) {
|
|
59
|
+
if (this.aborted || !this.centroid) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
63
|
+
for (const id in this.touches) {
|
|
64
|
+
if (this.touches[id]) {
|
|
65
|
+
const prevPos = this.touches[id];
|
|
66
|
+
const pos = newTouches[id];
|
|
67
|
+
if (!pos || pos.dist(prevPos) > MAX_DIST) {
|
|
68
|
+
this.aborted = true;
|
|
83
69
|
}
|
|
84
70
|
}
|
|
85
71
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return centroid;
|
|
97
|
-
}
|
|
72
|
+
}
|
|
73
|
+
touchend(e, points, mapTouches) {
|
|
74
|
+
if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
|
|
75
|
+
this.aborted = true;
|
|
76
|
+
}
|
|
77
|
+
if (mapTouches.length === 0) {
|
|
78
|
+
const centroid = !this.aborted && this.centroid;
|
|
79
|
+
this.reset();
|
|
80
|
+
if (centroid) {
|
|
81
|
+
return centroid;
|
|
98
82
|
}
|
|
99
83
|
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.default = SingleTapRecognizer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import TapRecognizer from './tap_recognizer';
|
|
3
|
+
export default class TapDragZoomHandler {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
active: boolean;
|
|
6
|
+
swipePoint: Point;
|
|
7
|
+
swipeTouch: number;
|
|
8
|
+
tapTime: number;
|
|
9
|
+
tap: TapRecognizer;
|
|
10
|
+
constructor();
|
|
11
|
+
reset(): void;
|
|
12
|
+
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
13
|
+
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
|
|
14
|
+
zoomDelta: number;
|
|
15
|
+
} | undefined;
|
|
16
|
+
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
17
|
+
touchcancel(): void;
|
|
18
|
+
enable(): void;
|
|
19
|
+
disable(): void;
|
|
20
|
+
isEnabled(): boolean;
|
|
21
|
+
isActive(): boolean;
|
|
22
|
+
}
|
|
@@ -5,107 +5,93 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _single_tap_recognizer = require("./single_tap_recognizer");
|
|
11
10
|
var _tap_recognizer = _interopRequireDefault(require("./tap_recognizer"));
|
|
12
11
|
// @ts-ignore
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
class TapDragZoomHandler {
|
|
14
|
+
constructor() {
|
|
15
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "swipePoint", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "swipeTouch", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "tapTime", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "tap", void 0);
|
|
16
21
|
this.tap = new _tap_recognizer.default({
|
|
17
22
|
numTouches: 1,
|
|
18
23
|
numTaps: 1
|
|
19
24
|
});
|
|
20
25
|
this.reset();
|
|
21
26
|
}
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
reset() {
|
|
28
|
+
this.active = false;
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
delete this.swipePoint;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
delete this.swipeTouch;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
delete this.tapTime;
|
|
35
|
+
this.tap.reset();
|
|
36
|
+
}
|
|
37
|
+
touchstart(e, points, mapTouches) {
|
|
38
|
+
if (this.swipePoint) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (this.tapTime && e.timeStamp - this.tapTime > _single_tap_recognizer.MAX_TAP_INTERVAL) {
|
|
42
|
+
this.reset();
|
|
33
43
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
if (!this.tapTime) {
|
|
45
|
+
this.tap.touchstart(e, points, mapTouches);
|
|
46
|
+
} else if (mapTouches.length > 0) {
|
|
47
|
+
this.swipePoint = points[0];
|
|
48
|
+
this.swipeTouch = mapTouches[0].identifier;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
touchmove(e, points, mapTouches) {
|
|
52
|
+
if (!this.tapTime) {
|
|
53
|
+
this.tap.touchmove(e, points, mapTouches);
|
|
54
|
+
} else if (this.swipePoint) {
|
|
55
|
+
if (mapTouches[0].identifier !== this.swipeTouch) {
|
|
38
56
|
return;
|
|
39
57
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
58
|
+
const newSwipePoint = points[0];
|
|
59
|
+
const dist = newSwipePoint.y - this.swipePoint.y;
|
|
60
|
+
this.swipePoint = newSwipePoint;
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
this.active = true;
|
|
63
|
+
return {
|
|
64
|
+
zoomDelta: dist / 128
|
|
65
|
+
};
|
|
49
66
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (mapTouches[0].identifier !== this.swipeTouch) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
var newSwipePoint = points[0];
|
|
60
|
-
var dist = newSwipePoint.y - this.swipePoint.y;
|
|
61
|
-
this.swipePoint = newSwipePoint;
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
this.active = true;
|
|
64
|
-
return {
|
|
65
|
-
zoomDelta: dist / 128
|
|
66
|
-
};
|
|
67
|
+
}
|
|
68
|
+
touchend(e, points, mapTouches) {
|
|
69
|
+
if (!this.tapTime) {
|
|
70
|
+
const point = this.tap.touchend(e, points, mapTouches);
|
|
71
|
+
if (point) {
|
|
72
|
+
this.tapTime = e.timeStamp;
|
|
67
73
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
value: function touchend(e, points, mapTouches) {
|
|
72
|
-
if (!this.tapTime) {
|
|
73
|
-
var point = this.tap.touchend(e, points, mapTouches);
|
|
74
|
-
if (point) {
|
|
75
|
-
this.tapTime = e.timeStamp;
|
|
76
|
-
}
|
|
77
|
-
} else if (this.swipePoint) {
|
|
78
|
-
if (mapTouches.length === 0) {
|
|
79
|
-
this.reset();
|
|
80
|
-
}
|
|
74
|
+
} else if (this.swipePoint) {
|
|
75
|
+
if (mapTouches.length === 0) {
|
|
76
|
+
this.reset();
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return this.enabled;
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "isActive",
|
|
106
|
-
value: function isActive() {
|
|
107
|
-
return this.active;
|
|
108
|
-
}
|
|
109
|
-
}]);
|
|
110
|
-
return TapDragZoomHandler;
|
|
111
|
-
}();
|
|
79
|
+
}
|
|
80
|
+
touchcancel() {
|
|
81
|
+
this.reset();
|
|
82
|
+
}
|
|
83
|
+
enable() {
|
|
84
|
+
this.enabled = true;
|
|
85
|
+
}
|
|
86
|
+
disable() {
|
|
87
|
+
this.enabled = false;
|
|
88
|
+
this.reset();
|
|
89
|
+
}
|
|
90
|
+
isEnabled() {
|
|
91
|
+
return this.enabled;
|
|
92
|
+
}
|
|
93
|
+
isActive() {
|
|
94
|
+
return this.active;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.default = TapDragZoomHandler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import SingleTapRecognizer from './single_tap_recognizer';
|
|
3
|
+
export default class TapRecognizer {
|
|
4
|
+
singleTap: SingleTapRecognizer;
|
|
5
|
+
numTaps: number;
|
|
6
|
+
lastTime: number;
|
|
7
|
+
lastTap: Point;
|
|
8
|
+
count: number;
|
|
9
|
+
constructor(options: {
|
|
10
|
+
numTaps: number;
|
|
11
|
+
numTouches: number;
|
|
12
|
+
});
|
|
13
|
+
reset(): void;
|
|
14
|
+
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
15
|
+
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
16
|
+
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
|
|
17
|
+
}
|