@antv/l7-map 2.17.12 → 2.18.0
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 +92 -149
- package/es/earthmap.js +15 -68
- package/es/geo/edge_insets.js +4 -14
- package/es/geo/lng_lat.js +5 -13
- package/es/geo/lng_lat_bounds.js +4 -17
- package/es/geo/mercator.js +2 -10
- package/es/geo/point.js +0 -7
- package/es/geo/simple.js +6 -11
- package/es/geo/transform.js +128 -138
- package/es/handler/blockable_map_event.js +7 -12
- package/es/handler/box_zoom.js +10 -30
- package/es/handler/click_zoom.js +0 -5
- package/es/handler/events/event.js +2 -3
- package/es/handler/events/map_mouse_event.js +2 -13
- package/es/handler/events/map_touch_event.js +2 -12
- package/es/handler/events/map_wheel_event.js +1 -12
- package/es/handler/events/render_event.js +0 -13
- package/es/handler/handler_inertia.js +8 -35
- package/es/handler/handler_manager.js +90 -197
- package/es/handler/handler_util.js +1 -2
- package/es/handler/keyboard.js +1 -20
- package/es/handler/map_event.js +3 -9
- package/es/handler/mouse/mouse_handler.js +11 -24
- package/es/handler/mouse/mousepan_handler.js +1 -11
- package/es/handler/mouse/mousepitch_hander.js +1 -11
- package/es/handler/mouse/mouserotate_hander.js +1 -11
- package/es/handler/mouse/util.js +2 -3
- package/es/handler/scroll_zoom.js +43 -71
- package/es/handler/shim/dblclick_zoom.js +4 -9
- package/es/handler/shim/drag_pan.js +6 -18
- package/es/handler/shim/drag_rotate.js +4 -10
- package/es/handler/shim/touch_zoom_rotate.js +8 -23
- package/es/handler/tap/single_tap_recognizer.js +8 -31
- package/es/handler/tap/tap_drag_zoom.js +7 -15
- package/es/handler/tap/tap_recognizer.js +3 -11
- package/es/handler/tap/tap_zoom.js +1 -7
- package/es/handler/touch/touch_pan.js +4 -22
- package/es/handler/touch/touch_pitch.js +10 -27
- package/es/handler/touch/touch_rotate.js +8 -19
- package/es/handler/touch/touch_zoom.js +5 -18
- package/es/handler/touch/two_touch.js +19 -32
- package/es/hash.js +13 -35
- package/es/map.js +30 -107
- package/es/util.d.ts +3 -3
- package/es/util.js +20 -33
- package/es/utils/Aabb.js +10 -31
- package/es/utils/dom.js +33 -111
- package/es/utils/performance.js +9 -9
- package/es/utils/primitives.js +13 -11
- package/es/utils/task_queue.js +6 -23
- package/lib/camera.js +102 -179
- package/lib/earthmap.js +14 -83
- package/lib/geo/edge_insets.js +3 -18
- package/lib/geo/lng_lat.js +5 -18
- package/lib/geo/lng_lat_bounds.js +4 -20
- package/lib/geo/mercator.js +1 -22
- package/lib/geo/point.js +0 -8
- package/lib/geo/simple.js +5 -24
- package/lib/geo/transform.js +128 -170
- package/lib/handler/blockable_map_event.js +6 -14
- package/lib/handler/box_zoom.js +8 -39
- package/lib/handler/click_zoom.js +0 -6
- package/lib/handler/events/event.js +4 -7
- package/lib/handler/events/index.js +0 -4
- package/lib/handler/events/map_mouse_event.js +5 -22
- package/lib/handler/events/map_touch_event.js +2 -21
- package/lib/handler/events/map_wheel_event.js +1 -16
- package/lib/handler/events/render_event.js +0 -19
- package/lib/handler/handler_inertia.js +13 -44
- package/lib/handler/handler_manager.js +92 -222
- package/lib/handler/handler_util.js +1 -3
- package/lib/handler/keyboard.js +1 -22
- package/lib/handler/map_event.js +2 -11
- package/lib/handler/mouse/index.js +0 -4
- package/lib/handler/mouse/mouse_handler.js +10 -27
- package/lib/handler/mouse/mousepan_handler.js +1 -18
- package/lib/handler/mouse/mousepitch_hander.js +1 -17
- package/lib/handler/mouse/mouserotate_hander.js +1 -17
- package/lib/handler/mouse/util.js +2 -6
- package/lib/handler/scroll_zoom.js +43 -77
- package/lib/handler/shim/dblclick_zoom.js +4 -10
- package/lib/handler/shim/drag_pan.js +6 -20
- package/lib/handler/shim/drag_rotate.js +4 -11
- package/lib/handler/shim/touch_zoom_rotate.js +8 -25
- package/lib/handler/tap/single_tap_recognizer.js +8 -33
- package/lib/handler/tap/tap_drag_zoom.js +6 -18
- package/lib/handler/tap/tap_recognizer.js +2 -17
- package/lib/handler/tap/tap_zoom.js +0 -9
- package/lib/handler/touch/index.js +0 -5
- package/lib/handler/touch/touch_pan.js +4 -25
- package/lib/handler/touch/touch_pitch.js +10 -32
- package/lib/handler/touch/touch_rotate.js +8 -25
- package/lib/handler/touch/touch_zoom.js +5 -24
- package/lib/handler/touch/two_touch.js +18 -35
- package/lib/hash.js +12 -38
- package/lib/index.js +0 -8
- package/lib/map.js +30 -125
- package/lib/util.js +19 -46
- package/lib/utils/Aabb.js +10 -34
- package/lib/utils/dom.js +32 -118
- package/lib/utils/performance.js +9 -11
- package/lib/utils/primitives.js +13 -16
- package/lib/utils/task_queue.js +6 -24
- package/package.json +4 -4
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { isMini } from '@antv/l7-utils';
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
|
|
7
5
|
* pinching on a touchscreen.
|
|
@@ -15,7 +13,6 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
15
13
|
*/
|
|
16
14
|
function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
|
|
17
15
|
_classCallCheck(this, TouchZoomRotateHandler);
|
|
18
|
-
|
|
19
16
|
this.el = el;
|
|
20
17
|
this.touchZoom = touchZoom;
|
|
21
18
|
this.touchRotate = touchRotate;
|
|
@@ -23,6 +20,7 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
23
20
|
this.rotationDisabled = false;
|
|
24
21
|
this.enabled = true;
|
|
25
22
|
}
|
|
23
|
+
|
|
26
24
|
/**
|
|
27
25
|
* Enables the "pinch to rotate and zoom" interaction.
|
|
28
26
|
*
|
|
@@ -34,63 +32,54 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
34
32
|
* @example
|
|
35
33
|
* map.touchZoomRotate.enable({ around: 'center' });
|
|
36
34
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
35
|
_createClass(TouchZoomRotateHandler, [{
|
|
40
36
|
key: "enable",
|
|
41
37
|
value: function enable(options) {
|
|
42
38
|
this.touchZoom.enable(options);
|
|
43
|
-
|
|
44
39
|
if (!this.rotationDisabled) {
|
|
45
40
|
this.touchRotate.enable(options);
|
|
46
41
|
}
|
|
47
|
-
|
|
48
42
|
this.tapDragZoom.enable();
|
|
49
|
-
|
|
50
|
-
if (!isMini) {
|
|
51
|
-
this.el.classList.add('l7-touch-zoom-rotate');
|
|
52
|
-
}
|
|
43
|
+
this.el.classList.add('l7-touch-zoom-rotate');
|
|
53
44
|
}
|
|
45
|
+
|
|
54
46
|
/**
|
|
55
47
|
* Disables the "pinch to rotate and zoom" interaction.
|
|
56
48
|
*
|
|
57
49
|
* @example
|
|
58
50
|
* map.touchZoomRotate.disable();
|
|
59
51
|
*/
|
|
60
|
-
|
|
61
52
|
}, {
|
|
62
53
|
key: "disable",
|
|
63
54
|
value: function disable() {
|
|
64
55
|
this.touchZoom.disable();
|
|
65
56
|
this.touchRotate.disable();
|
|
66
57
|
this.tapDragZoom.disable();
|
|
67
|
-
|
|
68
|
-
if (!isMini) {
|
|
69
|
-
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
70
|
-
}
|
|
58
|
+
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
71
59
|
}
|
|
60
|
+
|
|
72
61
|
/**
|
|
73
62
|
* Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
|
|
74
63
|
*
|
|
75
64
|
* @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
|
|
76
65
|
*/
|
|
77
|
-
|
|
78
66
|
}, {
|
|
79
67
|
key: "isEnabled",
|
|
80
68
|
value: function isEnabled() {
|
|
81
69
|
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
82
70
|
}
|
|
71
|
+
|
|
83
72
|
/**
|
|
84
73
|
* Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
|
|
85
74
|
*
|
|
86
75
|
* @returns {boolean} //eslint-disable-line
|
|
87
76
|
*/
|
|
88
|
-
|
|
89
77
|
}, {
|
|
90
78
|
key: "isActive",
|
|
91
79
|
value: function isActive() {
|
|
92
80
|
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
93
81
|
}
|
|
82
|
+
|
|
94
83
|
/**
|
|
95
84
|
* Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
|
|
96
85
|
* interaction enabled.
|
|
@@ -98,13 +87,13 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
98
87
|
* @example
|
|
99
88
|
* map.touchZoomRotate.disableRotation();
|
|
100
89
|
*/
|
|
101
|
-
|
|
102
90
|
}, {
|
|
103
91
|
key: "disableRotation",
|
|
104
92
|
value: function disableRotation() {
|
|
105
93
|
this.rotationDisabled = true;
|
|
106
94
|
this.touchRotate.disable();
|
|
107
95
|
}
|
|
96
|
+
|
|
108
97
|
/**
|
|
109
98
|
* Enables the "pinch to rotate" interaction.
|
|
110
99
|
*
|
|
@@ -112,19 +101,15 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
112
101
|
* map.touchZoomRotate.enable();
|
|
113
102
|
* map.touchZoomRotate.enableRotation();
|
|
114
103
|
*/
|
|
115
|
-
|
|
116
104
|
}, {
|
|
117
105
|
key: "enableRotation",
|
|
118
106
|
value: function enableRotation() {
|
|
119
107
|
this.rotationDisabled = false;
|
|
120
|
-
|
|
121
108
|
if (this.touchZoom.isEnabled()) {
|
|
122
109
|
this.touchRotate.enable();
|
|
123
110
|
}
|
|
124
111
|
}
|
|
125
112
|
}]);
|
|
126
|
-
|
|
127
113
|
return TouchZoomRotateHandler;
|
|
128
114
|
}();
|
|
129
|
-
|
|
130
115
|
export { TouchZoomRotateHandler as default };
|
|
@@ -1,58 +1,45 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
|
|
4
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
|
-
|
|
6
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
-
|
|
8
|
-
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; }
|
|
9
|
-
|
|
5
|
+
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; }
|
|
10
6
|
// @ts-ignore
|
|
11
7
|
import Point from "../../geo/point";
|
|
12
8
|
import { indexTouches } from "../handler_util";
|
|
13
|
-
|
|
14
9
|
function getCentroid(points) {
|
|
15
10
|
var sum = new Point(0, 0);
|
|
16
|
-
|
|
17
11
|
var _iterator = _createForOfIteratorHelper(points),
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
_step;
|
|
20
13
|
try {
|
|
21
14
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
22
15
|
var point = _step.value;
|
|
23
|
-
|
|
24
16
|
sum._add(point);
|
|
25
|
-
}
|
|
26
|
-
|
|
17
|
+
}
|
|
18
|
+
// @ts-ignore
|
|
27
19
|
} catch (err) {
|
|
28
20
|
_iterator.e(err);
|
|
29
21
|
} finally {
|
|
30
22
|
_iterator.f();
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
return sum.div(points.length);
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
export var MAX_TAP_INTERVAL = 500;
|
|
37
27
|
export var MAX_TOUCH_TIME = 500;
|
|
38
28
|
export var MAX_DIST = 30;
|
|
39
|
-
|
|
40
29
|
var SingleTapRecognizer = /*#__PURE__*/function () {
|
|
41
30
|
function SingleTapRecognizer(options) {
|
|
42
31
|
_classCallCheck(this, SingleTapRecognizer);
|
|
43
|
-
|
|
44
32
|
this.reset();
|
|
45
33
|
this.numTouches = options.numTouches;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
_createClass(SingleTapRecognizer, [{
|
|
49
36
|
key: "reset",
|
|
50
37
|
value: function reset() {
|
|
51
38
|
// @ts-ignore
|
|
52
|
-
delete this.centroid;
|
|
53
|
-
|
|
54
|
-
delete this.startTime;
|
|
55
|
-
|
|
39
|
+
delete this.centroid;
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
delete this.startTime;
|
|
42
|
+
// @ts-ignore
|
|
56
43
|
delete this.touches;
|
|
57
44
|
this.aborted = false;
|
|
58
45
|
}
|
|
@@ -62,15 +49,12 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
|
|
|
62
49
|
if (this.centroid || mapTouches.length > this.numTouches) {
|
|
63
50
|
this.aborted = true;
|
|
64
51
|
}
|
|
65
|
-
|
|
66
52
|
if (this.aborted) {
|
|
67
53
|
return;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
55
|
if (this.startTime === undefined) {
|
|
71
56
|
this.startTime = e.timeStamp;
|
|
72
57
|
}
|
|
73
|
-
|
|
74
58
|
if (mapTouches.length === this.numTouches) {
|
|
75
59
|
this.centroid = getCentroid(points);
|
|
76
60
|
this.touches = indexTouches(mapTouches, points);
|
|
@@ -82,14 +66,11 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
|
|
|
82
66
|
if (this.aborted || !this.centroid) {
|
|
83
67
|
return;
|
|
84
68
|
}
|
|
85
|
-
|
|
86
69
|
var newTouches = indexTouches(mapTouches, points);
|
|
87
|
-
|
|
88
70
|
for (var id in this.touches) {
|
|
89
71
|
if (this.touches[id]) {
|
|
90
72
|
var prevPos = this.touches[id];
|
|
91
73
|
var pos = newTouches[id];
|
|
92
|
-
|
|
93
74
|
if (!pos || pos.dist(prevPos) > MAX_DIST) {
|
|
94
75
|
this.aborted = true;
|
|
95
76
|
}
|
|
@@ -102,19 +83,15 @@ var SingleTapRecognizer = /*#__PURE__*/function () {
|
|
|
102
83
|
if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
|
|
103
84
|
this.aborted = true;
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
if (mapTouches.length === 0) {
|
|
107
87
|
var centroid = !this.aborted && this.centroid;
|
|
108
88
|
this.reset();
|
|
109
|
-
|
|
110
89
|
if (centroid) {
|
|
111
90
|
return centroid;
|
|
112
91
|
}
|
|
113
92
|
}
|
|
114
93
|
}
|
|
115
94
|
}]);
|
|
116
|
-
|
|
117
95
|
return SingleTapRecognizer;
|
|
118
96
|
}();
|
|
119
|
-
|
|
120
97
|
export { SingleTapRecognizer as default };
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
// @ts-ignore
|
|
4
|
+
|
|
4
5
|
import { MAX_TAP_INTERVAL } from "./single_tap_recognizer";
|
|
5
6
|
import TapRecognizer from "./tap_recognizer";
|
|
6
|
-
|
|
7
7
|
var TapDragZoomHandler = /*#__PURE__*/function () {
|
|
8
8
|
function TapDragZoomHandler() {
|
|
9
9
|
_classCallCheck(this, TapDragZoomHandler);
|
|
10
|
-
|
|
11
10
|
this.tap = new TapRecognizer({
|
|
12
11
|
numTouches: 1,
|
|
13
12
|
numTaps: 1
|
|
14
13
|
});
|
|
15
14
|
this.reset();
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
_createClass(TapDragZoomHandler, [{
|
|
19
17
|
key: "reset",
|
|
20
18
|
value: function reset() {
|
|
21
|
-
this.active = false;
|
|
22
|
-
|
|
23
|
-
delete this.swipePoint;
|
|
24
|
-
|
|
25
|
-
delete this.swipeTouch;
|
|
26
|
-
|
|
19
|
+
this.active = false;
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
delete this.swipePoint;
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
delete this.swipeTouch;
|
|
24
|
+
// @ts-ignore
|
|
27
25
|
delete this.tapTime;
|
|
28
26
|
this.tap.reset();
|
|
29
27
|
}
|
|
@@ -33,11 +31,9 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
|
|
|
33
31
|
if (this.swipePoint) {
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
if (this.tapTime && e.timeStamp - this.tapTime > MAX_TAP_INTERVAL) {
|
|
38
35
|
this.reset();
|
|
39
36
|
}
|
|
40
|
-
|
|
41
37
|
if (!this.tapTime) {
|
|
42
38
|
this.tap.touchstart(e, points, mapTouches);
|
|
43
39
|
} else if (mapTouches.length > 0) {
|
|
@@ -54,7 +50,6 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
|
|
|
54
50
|
if (mapTouches[0].identifier !== this.swipeTouch) {
|
|
55
51
|
return;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
var newSwipePoint = points[0];
|
|
59
54
|
var dist = newSwipePoint.y - this.swipePoint.y;
|
|
60
55
|
this.swipePoint = newSwipePoint;
|
|
@@ -70,7 +65,6 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
|
|
|
70
65
|
value: function touchend(e, points, mapTouches) {
|
|
71
66
|
if (!this.tapTime) {
|
|
72
67
|
var point = this.tap.touchend(e, points, mapTouches);
|
|
73
|
-
|
|
74
68
|
if (point) {
|
|
75
69
|
this.tapTime = e.timeStamp;
|
|
76
70
|
}
|
|
@@ -107,8 +101,6 @@ var TapDragZoomHandler = /*#__PURE__*/function () {
|
|
|
107
101
|
return this.active;
|
|
108
102
|
}
|
|
109
103
|
}]);
|
|
110
|
-
|
|
111
104
|
return TapDragZoomHandler;
|
|
112
105
|
}();
|
|
113
|
-
|
|
114
106
|
export { TapDragZoomHandler as default };
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
|
|
5
4
|
|
|
5
|
+
import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
|
|
6
6
|
var TapRecognizer = /*#__PURE__*/function () {
|
|
7
7
|
function TapRecognizer(options) {
|
|
8
8
|
_classCallCheck(this, TapRecognizer);
|
|
9
|
-
|
|
10
9
|
this.singleTap = new SingleTapRecognizer(options);
|
|
11
10
|
this.numTaps = options.numTaps;
|
|
12
11
|
this.reset();
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
_createClass(TapRecognizer, [{
|
|
16
14
|
key: "reset",
|
|
17
15
|
value: function reset() {
|
|
18
|
-
this.lastTime = Infinity;
|
|
19
|
-
|
|
16
|
+
this.lastTime = Infinity;
|
|
17
|
+
// @ts-ignore
|
|
20
18
|
delete this.lastTap;
|
|
21
19
|
this.count = 0;
|
|
22
20
|
this.singleTap.reset();
|
|
@@ -35,19 +33,15 @@ var TapRecognizer = /*#__PURE__*/function () {
|
|
|
35
33
|
key: "touchend",
|
|
36
34
|
value: function touchend(e, points, mapTouches) {
|
|
37
35
|
var tap = this.singleTap.touchend(e, points, mapTouches);
|
|
38
|
-
|
|
39
36
|
if (tap) {
|
|
40
37
|
var soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
|
|
41
38
|
var closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
|
|
42
|
-
|
|
43
39
|
if (!soonEnough || !closeEnough) {
|
|
44
40
|
this.reset();
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
this.count++;
|
|
48
43
|
this.lastTime = e.timeStamp;
|
|
49
44
|
this.lastTap = tap;
|
|
50
|
-
|
|
51
45
|
if (this.count === this.numTaps) {
|
|
52
46
|
this.reset();
|
|
53
47
|
return tap;
|
|
@@ -55,8 +49,6 @@ var TapRecognizer = /*#__PURE__*/function () {
|
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
51
|
}]);
|
|
58
|
-
|
|
59
52
|
return TapRecognizer;
|
|
60
53
|
}();
|
|
61
|
-
|
|
62
54
|
export { TapRecognizer as default };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
import TapRecognizer from "./tap_recognizer";
|
|
5
4
|
|
|
5
|
+
import TapRecognizer from "./tap_recognizer";
|
|
6
6
|
var TapZoomHandler = /*#__PURE__*/function () {
|
|
7
7
|
function TapZoomHandler() {
|
|
8
8
|
_classCallCheck(this, TapZoomHandler);
|
|
9
|
-
|
|
10
9
|
this.zoomIn = new TapRecognizer({
|
|
11
10
|
numTouches: 1,
|
|
12
11
|
numTaps: 2
|
|
@@ -17,7 +16,6 @@ var TapZoomHandler = /*#__PURE__*/function () {
|
|
|
17
16
|
});
|
|
18
17
|
this.reset();
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
_createClass(TapZoomHandler, [{
|
|
22
20
|
key: "reset",
|
|
23
21
|
value: function reset() {
|
|
@@ -41,10 +39,8 @@ var TapZoomHandler = /*#__PURE__*/function () {
|
|
|
41
39
|
key: "touchend",
|
|
42
40
|
value: function touchend(e, points, mapTouches) {
|
|
43
41
|
var _this = this;
|
|
44
|
-
|
|
45
42
|
var zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
|
|
46
43
|
var zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
|
|
47
|
-
|
|
48
44
|
if (zoomInPoint) {
|
|
49
45
|
this.active = true;
|
|
50
46
|
e.preventDefault();
|
|
@@ -108,8 +104,6 @@ var TapZoomHandler = /*#__PURE__*/function () {
|
|
|
108
104
|
return this.active;
|
|
109
105
|
}
|
|
110
106
|
}]);
|
|
111
|
-
|
|
112
107
|
return TapZoomHandler;
|
|
113
108
|
}();
|
|
114
|
-
|
|
115
109
|
export { TapZoomHandler as default };
|
|
@@ -3,16 +3,13 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import Point from "../../geo/point";
|
|
5
5
|
import { indexTouches } from "../handler_util";
|
|
6
|
-
|
|
7
6
|
var TouchPanHandler = /*#__PURE__*/function () {
|
|
8
7
|
function TouchPanHandler(options) {
|
|
9
8
|
_classCallCheck(this, TouchPanHandler);
|
|
10
|
-
|
|
11
9
|
this.minTouches = 1;
|
|
12
10
|
this.clickTolerance = options.clickTolerance || 1;
|
|
13
11
|
this.reset();
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
_createClass(TouchPanHandler, [{
|
|
17
14
|
key: "reset",
|
|
18
15
|
value: function reset() {
|
|
@@ -31,7 +28,6 @@ var TouchPanHandler = /*#__PURE__*/function () {
|
|
|
31
28
|
if (!this.active) {
|
|
32
29
|
return;
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
e.preventDefault();
|
|
36
32
|
return this.calculateTransform(e, points, mapTouches);
|
|
37
33
|
}
|
|
@@ -39,7 +35,6 @@ var TouchPanHandler = /*#__PURE__*/function () {
|
|
|
39
35
|
key: "touchend",
|
|
40
36
|
value: function touchend(e, points, mapTouches) {
|
|
41
37
|
this.calculateTransform(e, points, mapTouches);
|
|
42
|
-
|
|
43
38
|
if (this.active && mapTouches.length < this.minTouches) {
|
|
44
39
|
this.reset();
|
|
45
40
|
}
|
|
@@ -76,44 +71,33 @@ var TouchPanHandler = /*#__PURE__*/function () {
|
|
|
76
71
|
if (mapTouches.length > 0) {
|
|
77
72
|
this.active = true;
|
|
78
73
|
}
|
|
79
|
-
|
|
80
74
|
var touches = indexTouches(mapTouches, points);
|
|
81
75
|
var touchPointSum = new Point(0, 0);
|
|
82
76
|
var touchDeltaSum = new Point(0, 0);
|
|
83
77
|
var touchDeltaCount = 0;
|
|
84
|
-
|
|
85
78
|
for (var identifier in touches) {
|
|
86
79
|
if (touches[identifier]) {
|
|
87
80
|
var point = touches[identifier];
|
|
88
81
|
var prevPoint = this.touches[identifier];
|
|
89
|
-
|
|
90
82
|
if (prevPoint) {
|
|
91
83
|
touchPointSum._add(point);
|
|
92
|
-
|
|
93
84
|
touchDeltaSum._add(point.sub(prevPoint));
|
|
94
|
-
|
|
95
85
|
touchDeltaCount++;
|
|
96
86
|
touches[identifier] = point;
|
|
97
87
|
}
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
this.touches = touches;
|
|
102
|
-
|
|
103
91
|
if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
|
|
104
92
|
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
}
|
|
94
|
+
// @ts-ignore
|
|
108
95
|
var panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
109
|
-
|
|
110
96
|
this.sum._add(panDelta);
|
|
111
|
-
|
|
112
97
|
if (this.sum.mag() < this.clickTolerance) {
|
|
113
98
|
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
}
|
|
100
|
+
// @ts-ignore
|
|
117
101
|
var around = touchPointSum.div(touchDeltaCount);
|
|
118
102
|
return {
|
|
119
103
|
around: around,
|
|
@@ -121,8 +105,6 @@ var TouchPanHandler = /*#__PURE__*/function () {
|
|
|
121
105
|
};
|
|
122
106
|
}
|
|
123
107
|
}]);
|
|
124
|
-
|
|
125
108
|
return TouchPanHandler;
|
|
126
109
|
}();
|
|
127
|
-
|
|
128
110
|
export { TouchPanHandler as default };
|
|
@@ -4,47 +4,36 @@ import _get from "@babel/runtime/helpers/esm/get";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
|
|
8
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
8
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
9
|
// @ts-ignore
|
|
13
|
-
import TwoTouchHandler from "./two_touch";
|
|
14
10
|
|
|
11
|
+
import TwoTouchHandler from "./two_touch";
|
|
15
12
|
function isVertical(vector) {
|
|
16
13
|
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
var ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
20
|
-
|
|
21
16
|
var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
22
17
|
_inherits(TouchPitchHandler, _TwoTouchHandler);
|
|
23
|
-
|
|
24
18
|
var _super = _createSuper(TouchPitchHandler);
|
|
25
|
-
|
|
26
19
|
function TouchPitchHandler() {
|
|
27
20
|
_classCallCheck(this, TouchPitchHandler);
|
|
28
|
-
|
|
29
21
|
return _super.apply(this, arguments);
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
_createClass(TouchPitchHandler, [{
|
|
33
24
|
key: "reset",
|
|
34
25
|
value: function reset() {
|
|
35
26
|
_get(_getPrototypeOf(TouchPitchHandler.prototype), "reset", this).call(this);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
this.valid = undefined;
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
delete this.firstMove;
|
|
30
|
+
// @ts-ignore
|
|
41
31
|
delete this.lastPoints;
|
|
42
32
|
}
|
|
43
33
|
}, {
|
|
44
34
|
key: "start",
|
|
45
35
|
value: function start(points) {
|
|
46
36
|
this.lastPoints = points;
|
|
47
|
-
|
|
48
37
|
if (isVertical(points[0].sub(points[1]))) {
|
|
49
38
|
// fingers are more horizontal than vertical
|
|
50
39
|
this.valid = false;
|
|
@@ -56,11 +45,9 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
56
45
|
var vectorA = points[0].sub(this.lastPoints[0]);
|
|
57
46
|
var vectorB = points[1].sub(this.lastPoints[1]);
|
|
58
47
|
this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
59
|
-
|
|
60
48
|
if (!this.valid) {
|
|
61
49
|
return;
|
|
62
50
|
}
|
|
63
|
-
|
|
64
51
|
this.lastPoints = points;
|
|
65
52
|
this.active = true;
|
|
66
53
|
var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
@@ -75,22 +62,21 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
75
62
|
if (this.valid !== undefined) {
|
|
76
63
|
return this.valid;
|
|
77
64
|
}
|
|
78
|
-
|
|
79
65
|
var threshold = 2;
|
|
80
66
|
var movedA = vectorA.mag() >= threshold;
|
|
81
|
-
var movedB = vectorB.mag() >= threshold;
|
|
67
|
+
var movedB = vectorB.mag() >= threshold;
|
|
82
68
|
|
|
69
|
+
// neither finger has moved a meaningful amount, wait
|
|
83
70
|
if (!movedA && !movedB) {
|
|
84
71
|
return;
|
|
85
|
-
}
|
|
86
|
-
// If enough time has passed, decide it is not a pitch.
|
|
87
|
-
|
|
72
|
+
}
|
|
88
73
|
|
|
74
|
+
// One finger has moved and the other has not.
|
|
75
|
+
// If enough time has passed, decide it is not a pitch.
|
|
89
76
|
if (!movedA || !movedB) {
|
|
90
77
|
if (this.firstMove === undefined) {
|
|
91
78
|
this.firstMove = timeStamp;
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
95
81
|
// still waiting for a movement from the second finger
|
|
96
82
|
return undefined;
|
|
@@ -98,13 +84,10 @@ var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
98
84
|
return false;
|
|
99
85
|
}
|
|
100
86
|
}
|
|
101
|
-
|
|
102
87
|
var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
103
88
|
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
104
89
|
}
|
|
105
90
|
}]);
|
|
106
|
-
|
|
107
91
|
return TouchPitchHandler;
|
|
108
92
|
}(TwoTouchHandler);
|
|
109
|
-
|
|
110
93
|
export { TouchPitchHandler as default };
|
|
@@ -4,40 +4,32 @@ import _get from "@babel/runtime/helpers/esm/get";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
|
|
8
7
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
8
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
9
|
// @ts-ignore
|
|
10
|
+
|
|
13
11
|
import TwoTouchHandler from "./two_touch";
|
|
14
12
|
var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
15
13
|
|
|
16
14
|
function getBearingDelta(a, b) {
|
|
17
15
|
return a.angleWith(b) * 180 / Math.PI;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
21
18
|
_inherits(TouchRotateHandler, _TwoTouchHandler);
|
|
22
|
-
|
|
23
19
|
var _super = _createSuper(TouchRotateHandler);
|
|
24
|
-
|
|
25
20
|
function TouchRotateHandler() {
|
|
26
21
|
_classCallCheck(this, TouchRotateHandler);
|
|
27
|
-
|
|
28
22
|
return _super.apply(this, arguments);
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
_createClass(TouchRotateHandler, [{
|
|
32
25
|
key: "reset",
|
|
33
26
|
value: function reset() {
|
|
34
|
-
_get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
_get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this);
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
delete this.minDiameter;
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
delete this.startVector;
|
|
32
|
+
// @ts-ignore
|
|
41
33
|
delete this.vector;
|
|
42
34
|
}
|
|
43
35
|
}, {
|
|
@@ -51,11 +43,9 @@ var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
51
43
|
value: function move(points, pinchAround) {
|
|
52
44
|
var lastVector = this.vector;
|
|
53
45
|
this.vector = points[0].sub(points[1]);
|
|
54
|
-
|
|
55
46
|
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
56
47
|
return;
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
this.active = true;
|
|
60
50
|
return {
|
|
61
51
|
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
@@ -74,6 +64,7 @@ var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
74
64
|
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
75
65
|
* when pinching in and out.
|
|
76
66
|
*/
|
|
67
|
+
|
|
77
68
|
this.minDiameter = Math.min(this.minDiameter, vector.mag());
|
|
78
69
|
var circumference = Math.PI * this.minDiameter;
|
|
79
70
|
var threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
@@ -81,8 +72,6 @@ var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
|
81
72
|
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
82
73
|
}
|
|
83
74
|
}]);
|
|
84
|
-
|
|
85
75
|
return TouchRotateHandler;
|
|
86
76
|
}(TwoTouchHandler);
|
|
87
|
-
|
|
88
77
|
export { TouchRotateHandler as default };
|