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