@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,86 +1,120 @@
|
|
|
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/touch/touch_pitch.ts
|
|
23
|
-
var touch_pitch_exports = {};
|
|
24
|
-
__export(touch_pitch_exports, {
|
|
25
|
-
default: () => TouchPitchHandler
|
|
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
|
-
|
|
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 _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
|
+
|
|
26
|
+
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; } }
|
|
27
|
+
|
|
29
28
|
function isVertical(vector) {
|
|
30
29
|
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
31
30
|
}
|
|
31
|
+
|
|
32
32
|
var ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this
|
|
42
|
-
if (isVertical(points[0].sub(points[1]))) {
|
|
43
|
-
this.valid = false;
|
|
44
|
-
}
|
|
33
|
+
|
|
34
|
+
var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
35
|
+
(0, _inherits2.default)(TouchPitchHandler, _TwoTouchHandler);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(TouchPitchHandler);
|
|
38
|
+
|
|
39
|
+
function TouchPitchHandler() {
|
|
40
|
+
(0, _classCallCheck2.default)(this, TouchPitchHandler);
|
|
41
|
+
return _super.apply(this, arguments);
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
|
|
44
|
+
(0, _createClass2.default)(TouchPitchHandler, [{
|
|
45
|
+
key: "reset",
|
|
46
|
+
value: function reset() {
|
|
47
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(TouchPitchHandler.prototype), "reset", this).call(this);
|
|
48
|
+
this.valid = undefined; //@ts-ignore
|
|
49
|
+
|
|
50
|
+
delete this.firstMove; //@ts-ignore
|
|
51
|
+
|
|
52
|
+
delete this.lastPoints;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (this.valid !== void 0) {
|
|
63
|
-
return this.valid;
|
|
54
|
+
}, {
|
|
55
|
+
key: "start",
|
|
56
|
+
value: function start(points) {
|
|
57
|
+
this.lastPoints = points;
|
|
58
|
+
|
|
59
|
+
if (isVertical(points[0].sub(points[1]))) {
|
|
60
|
+
// fingers are more horizontal than vertical
|
|
61
|
+
this.valid = false;
|
|
62
|
+
}
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
}, {
|
|
65
|
+
key: "move",
|
|
66
|
+
value: function move(points, center, e) {
|
|
67
|
+
var vectorA = points[0].sub(this.lastPoints[0]);
|
|
68
|
+
var vectorB = points[1].sub(this.lastPoints[1]);
|
|
69
|
+
this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
70
|
+
|
|
71
|
+
if (!this.valid) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.lastPoints = points;
|
|
76
|
+
this.active = true;
|
|
77
|
+
var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
78
|
+
var degreesPerPixelMoved = -0.5;
|
|
79
|
+
return {
|
|
80
|
+
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
81
|
+
};
|
|
70
82
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
}, {
|
|
84
|
+
key: "gestureBeginsVertically",
|
|
85
|
+
value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
86
|
+
if (this.valid !== undefined) {
|
|
87
|
+
return this.valid;
|
|
74
88
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
|
|
90
|
+
var threshold = 2;
|
|
91
|
+
var movedA = vectorA.mag() >= threshold;
|
|
92
|
+
var movedB = vectorB.mag() >= threshold; // neither finger has moved a meaningful amount, wait
|
|
93
|
+
|
|
94
|
+
if (!movedA && !movedB) {
|
|
95
|
+
return;
|
|
96
|
+
} // One finger has moved and the other has not.
|
|
97
|
+
// If enough time has passed, decide it is not a pitch.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if (!movedA || !movedB) {
|
|
101
|
+
if (this.firstMove === undefined) {
|
|
102
|
+
this.firstMove = timeStamp;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
106
|
+
// still waiting for a movement from the second finger
|
|
107
|
+
return undefined;
|
|
108
|
+
} else {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
79
111
|
}
|
|
112
|
+
|
|
113
|
+
var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
114
|
+
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
80
115
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
0 && (module.exports = {});
|
|
116
|
+
}]);
|
|
117
|
+
return TouchPitchHandler;
|
|
118
|
+
}(_two_touch.default);
|
|
119
|
+
|
|
120
|
+
exports.default = TouchPitchHandler;
|
|
@@ -1,65 +1,99 @@
|
|
|
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/touch/touch_rotate.ts
|
|
23
|
-
var touch_rotate_exports = {};
|
|
24
|
-
__export(touch_rotate_exports, {
|
|
25
|
-
default: () => TouchRotateHandler
|
|
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
|
|
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 _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
|
+
|
|
26
|
+
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; } }
|
|
27
|
+
|
|
28
|
+
var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
29
|
+
|
|
30
30
|
function getBearingDelta(a, b) {
|
|
31
31
|
return a.angleWith(b) * 180 / Math.PI;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.minDiameter = points[0].dist(points[1]);
|
|
33
|
+
|
|
34
|
+
var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
35
|
+
(0, _inherits2.default)(TouchRotateHandler, _TwoTouchHandler);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(TouchRotateHandler);
|
|
38
|
+
|
|
39
|
+
function TouchRotateHandler() {
|
|
40
|
+
(0, _classCallCheck2.default)(this, TouchRotateHandler);
|
|
41
|
+
return _super.apply(this, arguments);
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
|
|
44
|
+
(0, _createClass2.default)(TouchRotateHandler, [{
|
|
45
|
+
key: "reset",
|
|
46
|
+
value: function reset() {
|
|
47
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(TouchRotateHandler.prototype), "reset", this).call(this); //@ts-ignore
|
|
48
|
+
|
|
49
|
+
delete this.minDiameter; //@ts-ignore
|
|
50
|
+
|
|
51
|
+
delete this.startVector; //@ts-ignore
|
|
52
|
+
|
|
53
|
+
delete this.vector;
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
}, {
|
|
56
|
+
key: "start",
|
|
57
|
+
value: function start(points) {
|
|
58
|
+
this.startVector = this.vector = points[0].sub(points[1]);
|
|
59
|
+
this.minDiameter = points[0].dist(points[1]);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "move",
|
|
63
|
+
value: function move(points, pinchAround) {
|
|
64
|
+
var lastVector = this.vector;
|
|
65
|
+
this.vector = points[0].sub(points[1]);
|
|
66
|
+
|
|
67
|
+
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.active = true;
|
|
72
|
+
return {
|
|
73
|
+
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
74
|
+
pinchAround: pinchAround
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "isBelowThreshold",
|
|
79
|
+
value: function isBelowThreshold(vector) {
|
|
80
|
+
/*
|
|
81
|
+
* The threshold before a rotation actually happens is configured in
|
|
82
|
+
* pixels alongth circumference of the circle formed by the two fingers.
|
|
83
|
+
* This makes the threshold in degrees larger when the fingers are close
|
|
84
|
+
* together and smaller when the fingers are far apart.
|
|
85
|
+
*
|
|
86
|
+
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
87
|
+
* when pinching in and out.
|
|
88
|
+
*/
|
|
89
|
+
this.minDiameter = Math.min(this.minDiameter, vector.mag());
|
|
90
|
+
var circumference = Math.PI * this.minDiameter;
|
|
91
|
+
var threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
92
|
+
var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
|
|
93
|
+
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
94
|
+
}
|
|
95
|
+
}]);
|
|
96
|
+
return TouchRotateHandler;
|
|
97
|
+
}(_two_touch.default);
|
|
98
|
+
|
|
99
|
+
exports.default = TouchRotateHandler;
|
|
@@ -1,56 +1,78 @@
|
|
|
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/touch/touch_zoom.ts
|
|
23
|
-
var touch_zoom_exports = {};
|
|
24
|
-
__export(touch_zoom_exports, {
|
|
25
|
-
default: () => TouchZoomHandler
|
|
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
|
-
|
|
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 _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
23
|
+
|
|
24
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
|
+
|
|
26
|
+
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; } }
|
|
27
|
+
|
|
29
28
|
var ZOOM_THRESHOLD = 0.1;
|
|
29
|
+
|
|
30
30
|
function getZoomDelta(distance, lastDistance) {
|
|
31
31
|
return Math.log(distance / lastDistance) / Math.LN2;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
|
|
34
|
+
var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
|
|
35
|
+
(0, _inherits2.default)(TouchZoomHandler, _TwoTouchHandler);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(TouchZoomHandler);
|
|
38
|
+
|
|
39
|
+
function TouchZoomHandler() {
|
|
40
|
+
(0, _classCallCheck2.default)(this, TouchZoomHandler);
|
|
41
|
+
return _super.apply(this, arguments);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
|
|
44
|
+
(0, _createClass2.default)(TouchZoomHandler, [{
|
|
45
|
+
key: "reset",
|
|
46
|
+
value: function reset() {
|
|
47
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(TouchZoomHandler.prototype), "reset", this).call(this); //@ts-ignore
|
|
48
|
+
|
|
49
|
+
delete this.distance; //@ts-ignore
|
|
50
|
+
|
|
51
|
+
delete this.startDistance;
|
|
47
52
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
}, {
|
|
54
|
+
key: "start",
|
|
55
|
+
value: function start(points) {
|
|
56
|
+
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "move",
|
|
60
|
+
value: function move(points, pinchAround) {
|
|
61
|
+
var lastDistance = this.distance;
|
|
62
|
+
this.distance = points[0].dist(points[1]);
|
|
63
|
+
|
|
64
|
+
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.active = true;
|
|
69
|
+
return {
|
|
70
|
+
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
71
|
+
pinchAround: pinchAround
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
return TouchZoomHandler;
|
|
76
|
+
}(_two_touch.default);
|
|
77
|
+
|
|
78
|
+
exports.default = TouchZoomHandler;
|