@antv/l7-map 2.5.33 → 2.5.37-mini
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.map +1 -1
- package/lib/earthmap.js +7 -26
- package/lib/earthmap.js.map +1 -1
- package/lib/handler/handler_manager.js +55 -33
- package/lib/handler/handler_manager.js.map +1 -1
- package/lib/handler/scroll_zoom.js +1 -1
- package/lib/handler/scroll_zoom.js.map +1 -1
- package/lib/handler/shim/drag_pan.js +10 -2
- package/lib/handler/shim/drag_pan.js.map +1 -1
- package/lib/handler/shim/touch_zoom_rotate.js +10 -2
- package/lib/handler/shim/touch_zoom_rotate.js.map +1 -1
- package/lib/hash.js +9 -4
- package/lib/hash.js.map +1 -1
- package/lib/map.js +39 -19
- package/lib/map.js.map +1 -1
- package/lib/util.js +7 -5
- package/lib/util.js.map +1 -1
- package/lib/utils/dom.js +66 -26
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/performance.js +4 -1
- package/lib/utils/performance.js.map +1 -1
- package/package.json +3 -3
- package/LICENSE.md +0 -21
- package/es/camera.d.ts +0 -82
- package/es/camera.js +0 -729
- package/es/camera.js.map +0 -1
- package/es/earthmap.d.ts +0 -67
- package/es/earthmap.js +0 -454
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/edge_insets.js +0 -88
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -77
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.d.ts +0 -24
- package/es/geo/lng_lat_bounds.js +0 -170
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.d.ts +0 -28
- package/es/geo/mercator.js +0 -79
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -237
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.d.ts +0 -28
- package/es/geo/simple.js +0 -78
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -663
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -2
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -84
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.d.ts +0 -59
- package/es/handler/box_zoom.js +0 -184
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -64
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -14
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -5
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -65
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -52
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.d.ts +0 -5
- package/es/handler/events/render_event.js +0 -41
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_inertia.js +0 -186
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.d.ts +0 -57
- package/es/handler/handler_manager.js +0 -655
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/handler_util.js +0 -10
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -157
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -120
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -5
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -131
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -54
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -54
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -54
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -317
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.d.ts +0 -40
- package/es/handler/shim/dblclick_zoom.js +0 -45
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -53
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.d.ts +0 -46
- package/es/handler/shim/drag_rotate.js +0 -51
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -80
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -127
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -124
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -72
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -124
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -6
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -139
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -120
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -88
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -79
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -140
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.d.ts +0 -15
- package/es/hash.js +0 -143
- package/es/hash.js.map +0 -1
- package/es/index.d.ts +0 -2
- package/es/index.js +0 -3
- package/es/index.js.map +0 -1
- package/es/interface.d.ts +0 -31
- package/es/interface.js +0 -2
- package/es/interface.js.map +0 -1
- package/es/map.d.ts +0 -67
- package/es/map.js +0 -454
- package/es/map.js.map +0 -1
- package/es/util.d.ts +0 -18
- package/es/util.js +0 -74
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -134
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -165
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -57
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -44
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -113
- package/es/utils/task_queue.js.map +0 -1
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import Point from '../../geo/point';
|
|
5
|
-
import { indexTouches } from '../handler_util';
|
|
6
|
-
|
|
7
|
-
var TouchPanHandler = function () {
|
|
8
|
-
function TouchPanHandler(options) {
|
|
9
|
-
_classCallCheck(this, TouchPanHandler);
|
|
10
|
-
|
|
11
|
-
_defineProperty(this, "enabled", void 0);
|
|
12
|
-
|
|
13
|
-
_defineProperty(this, "active", void 0);
|
|
14
|
-
|
|
15
|
-
_defineProperty(this, "touches", void 0);
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "minTouches", void 0);
|
|
18
|
-
|
|
19
|
-
_defineProperty(this, "clickTolerance", void 0);
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "sum", void 0);
|
|
22
|
-
|
|
23
|
-
this.minTouches = 1;
|
|
24
|
-
this.clickTolerance = options.clickTolerance || 1;
|
|
25
|
-
this.reset();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
_createClass(TouchPanHandler, [{
|
|
29
|
-
key: "reset",
|
|
30
|
-
value: function reset() {
|
|
31
|
-
this.active = false;
|
|
32
|
-
this.touches = {};
|
|
33
|
-
this.sum = new Point(0, 0);
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "touchstart",
|
|
37
|
-
value: function touchstart(e, points, mapTouches) {
|
|
38
|
-
return this.calculateTransform(e, points, mapTouches);
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
key: "touchmove",
|
|
42
|
-
value: function touchmove(e, points, mapTouches) {
|
|
43
|
-
if (!this.active) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
return this.calculateTransform(e, points, mapTouches);
|
|
49
|
-
}
|
|
50
|
-
}, {
|
|
51
|
-
key: "touchend",
|
|
52
|
-
value: function touchend(e, points, mapTouches) {
|
|
53
|
-
this.calculateTransform(e, points, mapTouches);
|
|
54
|
-
|
|
55
|
-
if (this.active && mapTouches.length < this.minTouches) {
|
|
56
|
-
this.reset();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "touchcancel",
|
|
61
|
-
value: function touchcancel() {
|
|
62
|
-
this.reset();
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "enable",
|
|
66
|
-
value: function enable() {
|
|
67
|
-
this.enabled = true;
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "disable",
|
|
71
|
-
value: function disable() {
|
|
72
|
-
this.enabled = false;
|
|
73
|
-
this.reset();
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "isEnabled",
|
|
77
|
-
value: function isEnabled() {
|
|
78
|
-
return this.enabled;
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "isActive",
|
|
82
|
-
value: function isActive() {
|
|
83
|
-
return this.active;
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "calculateTransform",
|
|
87
|
-
value: function calculateTransform(e, points, mapTouches) {
|
|
88
|
-
if (mapTouches.length > 0) {
|
|
89
|
-
this.active = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var touches = indexTouches(mapTouches, points);
|
|
93
|
-
var touchPointSum = new Point(0, 0);
|
|
94
|
-
var touchDeltaSum = new Point(0, 0);
|
|
95
|
-
var touchDeltaCount = 0;
|
|
96
|
-
|
|
97
|
-
for (var identifier in touches) {
|
|
98
|
-
if (touches[identifier]) {
|
|
99
|
-
var point = touches[identifier];
|
|
100
|
-
var prevPoint = this.touches[identifier];
|
|
101
|
-
|
|
102
|
-
if (prevPoint) {
|
|
103
|
-
touchPointSum._add(point);
|
|
104
|
-
|
|
105
|
-
touchDeltaSum._add(point.sub(prevPoint));
|
|
106
|
-
|
|
107
|
-
touchDeltaCount++;
|
|
108
|
-
touches[identifier] = point;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
this.touches = touches;
|
|
114
|
-
|
|
115
|
-
if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
var panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
120
|
-
|
|
121
|
-
this.sum._add(panDelta);
|
|
122
|
-
|
|
123
|
-
if (this.sum.mag() < this.clickTolerance) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var around = touchPointSum.div(touchDeltaCount);
|
|
128
|
-
return {
|
|
129
|
-
around: around,
|
|
130
|
-
panDelta: panDelta
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}]);
|
|
134
|
-
|
|
135
|
-
return TouchPanHandler;
|
|
136
|
-
}();
|
|
137
|
-
|
|
138
|
-
export { TouchPanHandler as default };
|
|
139
|
-
//# sourceMappingURL=touch_pan.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handler/touch/touch_pan.ts"],"names":["Point","indexTouches","TouchPanHandler","options","minTouches","clickTolerance","reset","active","touches","sum","e","points","mapTouches","calculateTransform","preventDefault","length","enabled","touchPointSum","touchDeltaSum","touchDeltaCount","identifier","point","prevPoint","_add","sub","mag","panDelta","div","around"],"mappings":"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","sourcesContent":["// @ts-ignore\nimport Point from '../../geo/point';\nimport { indexTouches } from '../handler_util';\n\nexport default class TouchPanHandler {\n public enabled: boolean;\n public active: boolean;\n public touches: { [key: string]: Point };\n public minTouches: number;\n public clickTolerance: number;\n public sum: Point;\n\n constructor(options: { clickTolerance: number }) {\n this.minTouches = 1;\n this.clickTolerance = options.clickTolerance || 1;\n this.reset();\n }\n\n public reset() {\n this.active = false;\n this.touches = {};\n this.sum = new Point(0, 0);\n }\n\n public touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n return this.calculateTransform(e, points, mapTouches);\n }\n\n public touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n if (!this.active) {\n return;\n }\n e.preventDefault();\n return this.calculateTransform(e, points, mapTouches);\n }\n\n public touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n this.calculateTransform(e, points, mapTouches);\n\n if (this.active && mapTouches.length < this.minTouches) {\n this.reset();\n }\n }\n\n public touchcancel() {\n this.reset();\n }\n public enable() {\n this.enabled = true;\n }\n\n public disable() {\n this.enabled = false;\n this.reset();\n }\n\n public isEnabled() {\n return this.enabled;\n }\n\n public isActive() {\n return this.active;\n }\n\n private calculateTransform(\n e: TouchEvent,\n points: Point[],\n mapTouches: Touch[],\n ) {\n if (mapTouches.length > 0) {\n this.active = true;\n }\n\n const touches = indexTouches(mapTouches, points);\n\n const touchPointSum = new Point(0, 0);\n const touchDeltaSum = new Point(0, 0);\n let touchDeltaCount = 0;\n\n for (const identifier in touches) {\n if (touches[identifier]) {\n const point = touches[identifier];\n const prevPoint = this.touches[identifier];\n if (prevPoint) {\n touchPointSum._add(point);\n touchDeltaSum._add(point.sub(prevPoint));\n touchDeltaCount++;\n touches[identifier] = point;\n }\n }\n }\n\n this.touches = touches;\n\n if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {\n return;\n }\n // @ts-ignore\n const panDelta = touchDeltaSum.div(touchDeltaCount);\n this.sum._add(panDelta);\n if (this.sum.mag() < this.clickTolerance) {\n return;\n }\n // @ts-ignore\n const around = touchPointSum.div(touchDeltaCount);\n\n return {\n around,\n panDelta,\n };\n }\n}\n"],"file":"touch_pan.js"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchPitchHandler extends TwoTouchHandler {
|
|
4
|
-
valid: boolean | void;
|
|
5
|
-
firstMove: number;
|
|
6
|
-
lastPoints: [Point, Point];
|
|
7
|
-
reset(): void;
|
|
8
|
-
start(points: [Point, Point]): void;
|
|
9
|
-
move(points: [Point, Point], center: Point, e: TouchEvent): {
|
|
10
|
-
pitchDelta: number;
|
|
11
|
-
} | undefined;
|
|
12
|
-
gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number): boolean | undefined;
|
|
13
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
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); }; }
|
|
11
|
-
|
|
12
|
-
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; } }
|
|
13
|
-
|
|
14
|
-
import TwoTouchHandler from './two_touch';
|
|
15
|
-
|
|
16
|
-
function isVertical(vector) {
|
|
17
|
-
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
21
|
-
|
|
22
|
-
var TouchPitchHandler = function (_TwoTouchHandler) {
|
|
23
|
-
_inherits(TouchPitchHandler, _TwoTouchHandler);
|
|
24
|
-
|
|
25
|
-
var _super = _createSuper(TouchPitchHandler);
|
|
26
|
-
|
|
27
|
-
function TouchPitchHandler() {
|
|
28
|
-
var _this;
|
|
29
|
-
|
|
30
|
-
_classCallCheck(this, TouchPitchHandler);
|
|
31
|
-
|
|
32
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
|
-
args[_key] = arguments[_key];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
37
|
-
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "valid", void 0);
|
|
39
|
-
|
|
40
|
-
_defineProperty(_assertThisInitialized(_this), "firstMove", void 0);
|
|
41
|
-
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "lastPoints", void 0);
|
|
43
|
-
|
|
44
|
-
return _this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_createClass(TouchPitchHandler, [{
|
|
48
|
-
key: "reset",
|
|
49
|
-
value: function reset() {
|
|
50
|
-
_get(_getPrototypeOf(TouchPitchHandler.prototype), "reset", this).call(this);
|
|
51
|
-
|
|
52
|
-
this.valid = undefined;
|
|
53
|
-
delete this.firstMove;
|
|
54
|
-
delete this.lastPoints;
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "start",
|
|
58
|
-
value: function start(points) {
|
|
59
|
-
this.lastPoints = points;
|
|
60
|
-
|
|
61
|
-
if (isVertical(points[0].sub(points[1]))) {
|
|
62
|
-
this.valid = false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "move",
|
|
67
|
-
value: function move(points, center, e) {
|
|
68
|
-
var vectorA = points[0].sub(this.lastPoints[0]);
|
|
69
|
-
var vectorB = points[1].sub(this.lastPoints[1]);
|
|
70
|
-
this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
71
|
-
|
|
72
|
-
if (!this.valid) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.lastPoints = points;
|
|
77
|
-
this.active = true;
|
|
78
|
-
var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
79
|
-
var degreesPerPixelMoved = -0.5;
|
|
80
|
-
return {
|
|
81
|
-
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "gestureBeginsVertically",
|
|
86
|
-
value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
87
|
-
if (this.valid !== undefined) {
|
|
88
|
-
return this.valid;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var threshold = 2;
|
|
92
|
-
var movedA = vectorA.mag() >= threshold;
|
|
93
|
-
var movedB = vectorB.mag() >= threshold;
|
|
94
|
-
|
|
95
|
-
if (!movedA && !movedB) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!movedA || !movedB) {
|
|
100
|
-
if (this.firstMove === undefined) {
|
|
101
|
-
this.firstMove = timeStamp;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
105
|
-
return undefined;
|
|
106
|
-
} else {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
112
|
-
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
115
|
-
|
|
116
|
-
return TouchPitchHandler;
|
|
117
|
-
}(TwoTouchHandler);
|
|
118
|
-
|
|
119
|
-
export { TouchPitchHandler as default };
|
|
120
|
-
//# sourceMappingURL=touch_pitch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handler/touch/touch_pitch.ts"],"names":["TwoTouchHandler","isVertical","vector","Math","abs","y","x","ALLOWED_SINGLE_TOUCH_TIME","TouchPitchHandler","valid","undefined","firstMove","lastPoints","points","sub","center","e","vectorA","vectorB","gestureBeginsVertically","timeStamp","active","yDeltaAverage","degreesPerPixelMoved","pitchDelta","threshold","movedA","mag","movedB","isSameDirection"],"mappings":";;;;;;;;;;;;;AAEA,OAAOA,eAAP,MAA4B,aAA5B;;AAEA,SAASC,UAAT,CAAoBC,MAApB,EAAsD;AACpD,SAAOC,IAAI,CAACC,GAAL,CAASF,MAAM,CAACG,CAAhB,IAAqBF,IAAI,CAACC,GAAL,CAASF,MAAM,CAACI,CAAhB,CAA5B;AACD;;AAED,IAAMC,yBAAyB,GAAG,GAAlC;;IAEqBC,iB;;;;;;;;;;;;;;;;;;;;;;;;;;;WAKnB,iBAAe;AACb;;AACA,WAAKC,KAAL,GAAaC,SAAb;AACA,aAAO,KAAKC,SAAZ;AACA,aAAO,KAAKC,UAAZ;AACD;;;WAED,eAAaC,MAAb,EAAqC;AACnC,WAAKD,UAAL,GAAkBC,MAAlB;;AACA,UAAIZ,UAAU,CAACY,MAAM,CAAC,CAAD,CAAN,CAAUC,GAAV,CAAcD,MAAM,CAAC,CAAD,CAApB,CAAD,CAAd,EAA0C;AAExC,aAAKJ,KAAL,GAAa,KAAb;AACD;AACF;;;WAED,cAAYI,MAAZ,EAAoCE,MAApC,EAAmDC,CAAnD,EAAkE;AAChE,UAAMC,OAAO,GAAGJ,MAAM,CAAC,CAAD,CAAN,CAAUC,GAAV,CAAc,KAAKF,UAAL,CAAgB,CAAhB,CAAd,CAAhB;AACA,UAAMM,OAAO,GAAGL,MAAM,CAAC,CAAD,CAAN,CAAUC,GAAV,CAAc,KAAKF,UAAL,CAAgB,CAAhB,CAAd,CAAhB;AAEA,WAAKH,KAAL,GAAa,KAAKU,uBAAL,CAA6BF,OAA7B,EAAsCC,OAAtC,EAA+CF,CAAC,CAACI,SAAjD,CAAb;;AACA,UAAI,CAAC,KAAKX,KAAV,EAAiB;AACf;AACD;;AAED,WAAKG,UAAL,GAAkBC,MAAlB;AACA,WAAKQ,MAAL,GAAc,IAAd;AACA,UAAMC,aAAa,GAAG,CAACL,OAAO,CAACZ,CAAR,GAAYa,OAAO,CAACb,CAArB,IAA0B,CAAhD;AACA,UAAMkB,oBAAoB,GAAG,CAAC,GAA9B;AACA,aAAO;AACLC,QAAAA,UAAU,EAAEF,aAAa,GAAGC;AADvB,OAAP;AAGD;;;WAED,iCACEN,OADF,EAEEC,OAFF,EAGEE,SAHF,EAIE;AACA,UAAI,KAAKX,KAAL,KAAeC,SAAnB,EAA8B;AAC5B,eAAO,KAAKD,KAAZ;AACD;;AAED,UAAMgB,SAAS,GAAG,CAAlB;AACA,UAAMC,MAAM,GAAGT,OAAO,CAACU,GAAR,MAAiBF,SAAhC;AACA,UAAMG,MAAM,GAAGV,OAAO,CAACS,GAAR,MAAiBF,SAAhC;;AAGA,UAAI,CAACC,MAAD,IAAW,CAACE,MAAhB,EAAwB;AACtB;AACD;;AAID,UAAI,CAACF,MAAD,IAAW,CAACE,MAAhB,EAAwB;AACtB,YAAI,KAAKjB,SAAL,KAAmBD,SAAvB,EAAkC;AAChC,eAAKC,SAAL,GAAiBS,SAAjB;AACD;;AAED,YAAIA,SAAS,GAAG,KAAKT,SAAjB,GAA6BJ,yBAAjC,EAA4D;AAE1D,iBAAOG,SAAP;AACD,SAHD,MAGO;AACL,iBAAO,KAAP;AACD;AACF;;AAED,UAAMmB,eAAe,GAAGZ,OAAO,CAACZ,CAAR,GAAY,CAAZ,KAAkBa,OAAO,CAACb,CAAR,GAAY,CAAtD;AACA,aAAOJ,UAAU,CAACgB,OAAD,CAAV,IAAuBhB,UAAU,CAACiB,OAAD,CAAjC,IAA8CW,eAArD;AACD;;;;EAzE4C7B,e;;SAA1BQ,iB","sourcesContent":["// @ts-ignore\nimport Point from '../../geo/point';\nimport TwoTouchHandler from './two_touch';\n\nfunction isVertical(vector: { x: number; y: number }) {\n return Math.abs(vector.y) > Math.abs(vector.x);\n}\n\nconst ALLOWED_SINGLE_TOUCH_TIME = 100;\n\nexport default class TouchPitchHandler extends TwoTouchHandler {\n public valid: boolean | void;\n public firstMove: number;\n public lastPoints: [Point, Point];\n\n public reset() {\n super.reset();\n this.valid = undefined;\n delete this.firstMove;\n delete this.lastPoints;\n }\n\n public start(points: [Point, Point]) {\n this.lastPoints = points;\n if (isVertical(points[0].sub(points[1]))) {\n // fingers are more horizontal than vertical\n this.valid = false;\n }\n }\n\n public move(points: [Point, Point], center: Point, e: TouchEvent) {\n const vectorA = points[0].sub(this.lastPoints[0]);\n const vectorB = points[1].sub(this.lastPoints[1]);\n\n this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);\n if (!this.valid) {\n return;\n }\n\n this.lastPoints = points;\n this.active = true;\n const yDeltaAverage = (vectorA.y + vectorB.y) / 2;\n const degreesPerPixelMoved = -0.5;\n return {\n pitchDelta: yDeltaAverage * degreesPerPixelMoved,\n };\n }\n\n public gestureBeginsVertically(\n vectorA: Point,\n vectorB: Point,\n timeStamp: number,\n ) {\n if (this.valid !== undefined) {\n return this.valid;\n }\n\n const threshold = 2;\n const movedA = vectorA.mag() >= threshold;\n const movedB = vectorB.mag() >= threshold;\n\n // neither finger has moved a meaningful amount, wait\n if (!movedA && !movedB) {\n return;\n }\n\n // One finger has moved and the other has not.\n // If enough time has passed, decide it is not a pitch.\n if (!movedA || !movedB) {\n if (this.firstMove === undefined) {\n this.firstMove = timeStamp;\n }\n\n if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {\n // still waiting for a movement from the second finger\n return undefined;\n } else {\n return false;\n }\n }\n\n const isSameDirection = vectorA.y > 0 === vectorB.y > 0;\n return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;\n }\n}\n"],"file":"touch_pitch.js"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchRotateHandler extends TwoTouchHandler {
|
|
4
|
-
private minDiameter;
|
|
5
|
-
reset(): void;
|
|
6
|
-
start(points: [Point, Point]): void;
|
|
7
|
-
move(points: [Point, Point], pinchAround: Point): {
|
|
8
|
-
bearingDelta: number;
|
|
9
|
-
pinchAround: Point;
|
|
10
|
-
} | undefined;
|
|
11
|
-
private isBelowThreshold;
|
|
12
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
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); }; }
|
|
11
|
-
|
|
12
|
-
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; } }
|
|
13
|
-
|
|
14
|
-
import TwoTouchHandler from './two_touch';
|
|
15
|
-
var ROTATION_THRESHOLD = 25;
|
|
16
|
-
|
|
17
|
-
function getBearingDelta(a, b) {
|
|
18
|
-
return a.angleWith(b) * 180 / Math.PI;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var TouchRotateHandler = function (_TwoTouchHandler) {
|
|
22
|
-
_inherits(TouchRotateHandler, _TwoTouchHandler);
|
|
23
|
-
|
|
24
|
-
var _super = _createSuper(TouchRotateHandler);
|
|
25
|
-
|
|
26
|
-
function TouchRotateHandler() {
|
|
27
|
-
var _this;
|
|
28
|
-
|
|
29
|
-
_classCallCheck(this, TouchRotateHandler);
|
|
30
|
-
|
|
31
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
-
args[_key] = arguments[_key];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
-
|
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "minDiameter", void 0);
|
|
38
|
-
|
|
39
|
-
return _this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_createClass(TouchRotateHandler, [{
|
|
43
|
-
key: "reset",
|
|
44
|
-
value: function reset() {
|
|
45
|
-
_get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this);
|
|
46
|
-
|
|
47
|
-
delete this.minDiameter;
|
|
48
|
-
delete this.startVector;
|
|
49
|
-
delete this.vector;
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "start",
|
|
53
|
-
value: function start(points) {
|
|
54
|
-
this.startVector = this.vector = points[0].sub(points[1]);
|
|
55
|
-
this.minDiameter = points[0].dist(points[1]);
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "move",
|
|
59
|
-
value: function move(points, pinchAround) {
|
|
60
|
-
var lastVector = this.vector;
|
|
61
|
-
this.vector = points[0].sub(points[1]);
|
|
62
|
-
|
|
63
|
-
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.active = true;
|
|
68
|
-
return {
|
|
69
|
-
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
70
|
-
pinchAround: pinchAround
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "isBelowThreshold",
|
|
75
|
-
value: function isBelowThreshold(vector) {
|
|
76
|
-
this.minDiameter = Math.min(this.minDiameter, vector.mag());
|
|
77
|
-
var circumference = Math.PI * this.minDiameter;
|
|
78
|
-
var threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
79
|
-
var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
|
|
80
|
-
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
81
|
-
}
|
|
82
|
-
}]);
|
|
83
|
-
|
|
84
|
-
return TouchRotateHandler;
|
|
85
|
-
}(TwoTouchHandler);
|
|
86
|
-
|
|
87
|
-
export { TouchRotateHandler as default };
|
|
88
|
-
//# sourceMappingURL=touch_rotate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handler/touch/touch_rotate.ts"],"names":["TwoTouchHandler","ROTATION_THRESHOLD","getBearingDelta","a","b","angleWith","Math","PI","TouchRotateHandler","minDiameter","startVector","vector","points","sub","dist","pinchAround","lastVector","active","isBelowThreshold","bearingDelta","min","mag","circumference","threshold","bearingDeltaSinceStart","abs"],"mappings":";;;;;;;;;;;;;AAGA,OAAOA,eAAP,MAA4B,aAA5B;AAEA,IAAMC,kBAAkB,GAAG,EAA3B;;AAEA,SAASC,eAAT,CAAyBC,CAAzB,EAAmCC,CAAnC,EAA6C;AAC3C,SAAQD,CAAC,CAACE,SAAF,CAAYD,CAAZ,IAAiB,GAAlB,GAAyBE,IAAI,CAACC,EAArC;AACD;;IAEoBC,kB;;;;;;;;;;;;;;;;;;;;;;;WAGnB,iBAAe;AACb;;AACA,aAAO,KAAKC,WAAZ;AACA,aAAO,KAAKC,WAAZ;AACA,aAAO,KAAKC,MAAZ;AACD;;;WAED,eAAaC,MAAb,EAAqC;AACnC,WAAKF,WAAL,GAAmB,KAAKC,MAAL,GAAcC,MAAM,CAAC,CAAD,CAAN,CAAUC,GAAV,CAAcD,MAAM,CAAC,CAAD,CAApB,CAAjC;AACA,WAAKH,WAAL,GAAmBG,MAAM,CAAC,CAAD,CAAN,CAAUE,IAAV,CAAeF,MAAM,CAAC,CAAD,CAArB,CAAnB;AACD;;;WAED,cAAYA,MAAZ,EAAoCG,WAApC,EAAwD;AACtD,UAAMC,UAAU,GAAG,KAAKL,MAAxB;AACA,WAAKA,MAAL,GAAcC,MAAM,CAAC,CAAD,CAAN,CAAUC,GAAV,CAAcD,MAAM,CAAC,CAAD,CAApB,CAAd;;AAEA,UAAI,CAAC,KAAKK,MAAN,IAAgB,KAAKC,gBAAL,CAAsB,KAAKP,MAA3B,CAApB,EAAwD;AACtD;AACD;;AACD,WAAKM,MAAL,GAAc,IAAd;AAEA,aAAO;AACLE,QAAAA,YAAY,EAAEjB,eAAe,CAAC,KAAKS,MAAN,EAAcK,UAAd,CADxB;AAELD,QAAAA,WAAW,EAAXA;AAFK,OAAP;AAID;;;WAED,0BAAyBJ,MAAzB,EAAwC;AAWtC,WAAKF,WAAL,GAAmBH,IAAI,CAACc,GAAL,CAAS,KAAKX,WAAd,EAA2BE,MAAM,CAACU,GAAP,EAA3B,CAAnB;AACA,UAAMC,aAAa,GAAGhB,IAAI,CAACC,EAAL,GAAU,KAAKE,WAArC;AACA,UAAMc,SAAS,GAAItB,kBAAkB,GAAGqB,aAAtB,GAAuC,GAAzD;AAEA,UAAME,sBAAsB,GAAGtB,eAAe,CAACS,MAAD,EAAS,KAAKD,WAAd,CAA9C;AACA,aAAOJ,IAAI,CAACmB,GAAL,CAASD,sBAAT,IAAmCD,SAA1C;AACD;;;;EA/C6CvB,e;;SAA3BQ,kB","sourcesContent":["// @ts-ignore\nimport Point from '../../geo/point';\nimport DOM from '../../utils/dom';\nimport TwoTouchHandler from './two_touch';\n\nconst ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle\n\nfunction getBearingDelta(a: Point, b: Point) {\n return (a.angleWith(b) * 180) / Math.PI;\n}\n\nexport default class TouchRotateHandler extends TwoTouchHandler {\n private minDiameter: number;\n\n public reset() {\n super.reset();\n delete this.minDiameter;\n delete this.startVector;\n delete this.vector;\n }\n\n public start(points: [Point, Point]) {\n this.startVector = this.vector = points[0].sub(points[1]);\n this.minDiameter = points[0].dist(points[1]);\n }\n\n public move(points: [Point, Point], pinchAround: Point) {\n const lastVector = this.vector;\n this.vector = points[0].sub(points[1]);\n\n if (!this.active && this.isBelowThreshold(this.vector)) {\n return;\n }\n this.active = true;\n\n return {\n bearingDelta: getBearingDelta(this.vector, lastVector),\n pinchAround,\n };\n }\n\n private isBelowThreshold(vector: Point) {\n /*\n * The threshold before a rotation actually happens is configured in\n * pixels alongth circumference of the circle formed by the two fingers.\n * This makes the threshold in degrees larger when the fingers are close\n * together and smaller when the fingers are far apart.\n *\n * Use the smallest diameter from the whole gesture to reduce sensitivity\n * when pinching in and out.\n */\n\n this.minDiameter = Math.min(this.minDiameter, vector.mag());\n const circumference = Math.PI * this.minDiameter;\n const threshold = (ROTATION_THRESHOLD / circumference) * 360;\n\n const bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);\n return Math.abs(bearingDeltaSinceStart) < threshold;\n }\n}\n"],"file":"touch_rotate.js"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Point from '../../geo/point';
|
|
2
|
-
import TwoTouchHandler from './two_touch';
|
|
3
|
-
export default class TouchZoomHandler extends TwoTouchHandler {
|
|
4
|
-
private distance;
|
|
5
|
-
private startDistance;
|
|
6
|
-
reset(): void;
|
|
7
|
-
start(points: [Point, Point]): void;
|
|
8
|
-
move(points: [Point, Point], pinchAround: Point): {
|
|
9
|
-
zoomDelta: number;
|
|
10
|
-
pinchAround: Point;
|
|
11
|
-
} | undefined;
|
|
12
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
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); }; }
|
|
11
|
-
|
|
12
|
-
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; } }
|
|
13
|
-
|
|
14
|
-
import TwoTouchHandler from './two_touch';
|
|
15
|
-
var ZOOM_THRESHOLD = 0.1;
|
|
16
|
-
|
|
17
|
-
function getZoomDelta(distance, lastDistance) {
|
|
18
|
-
return Math.log(distance / lastDistance) / Math.LN2;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var TouchZoomHandler = function (_TwoTouchHandler) {
|
|
22
|
-
_inherits(TouchZoomHandler, _TwoTouchHandler);
|
|
23
|
-
|
|
24
|
-
var _super = _createSuper(TouchZoomHandler);
|
|
25
|
-
|
|
26
|
-
function TouchZoomHandler() {
|
|
27
|
-
var _this;
|
|
28
|
-
|
|
29
|
-
_classCallCheck(this, TouchZoomHandler);
|
|
30
|
-
|
|
31
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
-
args[_key] = arguments[_key];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
-
|
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "distance", void 0);
|
|
38
|
-
|
|
39
|
-
_defineProperty(_assertThisInitialized(_this), "startDistance", void 0);
|
|
40
|
-
|
|
41
|
-
return _this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
_createClass(TouchZoomHandler, [{
|
|
45
|
-
key: "reset",
|
|
46
|
-
value: function reset() {
|
|
47
|
-
_get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this);
|
|
48
|
-
|
|
49
|
-
delete this.distance;
|
|
50
|
-
delete this.startDistance;
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "start",
|
|
54
|
-
value: function start(points) {
|
|
55
|
-
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "move",
|
|
59
|
-
value: function move(points, pinchAround) {
|
|
60
|
-
var lastDistance = this.distance;
|
|
61
|
-
this.distance = points[0].dist(points[1]);
|
|
62
|
-
|
|
63
|
-
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.active = true;
|
|
68
|
-
return {
|
|
69
|
-
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
70
|
-
pinchAround: pinchAround
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}]);
|
|
74
|
-
|
|
75
|
-
return TouchZoomHandler;
|
|
76
|
-
}(TwoTouchHandler);
|
|
77
|
-
|
|
78
|
-
export { TouchZoomHandler as default };
|
|
79
|
-
//# sourceMappingURL=touch_zoom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handler/touch/touch_zoom.ts"],"names":["TwoTouchHandler","ZOOM_THRESHOLD","getZoomDelta","distance","lastDistance","Math","log","LN2","TouchZoomHandler","startDistance","points","dist","pinchAround","active","abs","zoomDelta"],"mappings":";;;;;;;;;;;;;AAGA,OAAOA,eAAP,MAA4B,aAA5B;AAEA,IAAMC,cAAc,GAAG,GAAvB;;AACA,SAASC,YAAT,CAAsBC,QAAtB,EAAwCC,YAAxC,EAA8D;AAC5D,SAAOC,IAAI,CAACC,GAAL,CAASH,QAAQ,GAAGC,YAApB,IAAoCC,IAAI,CAACE,GAAhD;AACD;;IACoBC,gB;;;;;;;;;;;;;;;;;;;;;;;;;WAInB,iBAAe;AACb;;AACA,aAAO,KAAKL,QAAZ;AACA,aAAO,KAAKM,aAAZ;AACD;;;WAED,eAAaC,MAAb,EAAqC;AACnC,WAAKD,aAAL,GAAqB,KAAKN,QAAL,GAAgBO,MAAM,CAAC,CAAD,CAAN,CAAUC,IAAV,CAAeD,MAAM,CAAC,CAAD,CAArB,CAArC;AACD;;;WAED,cAAYA,MAAZ,EAAoCE,WAApC,EAAwD;AACtD,UAAMR,YAAY,GAAG,KAAKD,QAA1B;AACA,WAAKA,QAAL,GAAgBO,MAAM,CAAC,CAAD,CAAN,CAAUC,IAAV,CAAeD,MAAM,CAAC,CAAD,CAArB,CAAhB;;AACA,UACE,CAAC,KAAKG,MAAN,IACAR,IAAI,CAACS,GAAL,CAASZ,YAAY,CAAC,KAAKC,QAAN,EAAgB,KAAKM,aAArB,CAArB,IAA4DR,cAF9D,EAGE;AACA;AACD;;AACD,WAAKY,MAAL,GAAc,IAAd;AACA,aAAO;AACLE,QAAAA,SAAS,EAAEb,YAAY,CAAC,KAAKC,QAAN,EAAgBC,YAAhB,CADlB;AAELQ,QAAAA,WAAW,EAAXA;AAFK,OAAP;AAID;;;;EA5B2CZ,e;;SAAzBQ,gB","sourcesContent":["// @ts-ignore\nimport Point from '../../geo/point';\nimport DOM from '../../utils/dom';\nimport TwoTouchHandler from './two_touch';\n\nconst ZOOM_THRESHOLD = 0.1;\nfunction getZoomDelta(distance: number, lastDistance: number) {\n return Math.log(distance / lastDistance) / Math.LN2;\n}\nexport default class TouchZoomHandler extends TwoTouchHandler {\n private distance: number;\n private startDistance: number;\n\n public reset() {\n super.reset();\n delete this.distance;\n delete this.startDistance;\n }\n\n public start(points: [Point, Point]) {\n this.startDistance = this.distance = points[0].dist(points[1]);\n }\n\n public move(points: [Point, Point], pinchAround: Point) {\n const lastDistance = this.distance;\n this.distance = points[0].dist(points[1]);\n if (\n !this.active &&\n Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD\n ) {\n return;\n }\n this.active = true;\n return {\n zoomDelta: getZoomDelta(this.distance, lastDistance),\n pinchAround,\n };\n }\n}\n"],"file":"touch_zoom.js"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Point from '../../geo/point';
|
|
2
|
-
export default class TwoTouchHandler {
|
|
3
|
-
protected enabled: boolean;
|
|
4
|
-
protected active: boolean;
|
|
5
|
-
protected firstTwoTouches: [number, number];
|
|
6
|
-
protected vector: Point;
|
|
7
|
-
protected startVector: Point;
|
|
8
|
-
protected aroundCenter: boolean;
|
|
9
|
-
constructor();
|
|
10
|
-
reset(): void;
|
|
11
|
-
start(points: [Point, Point]): void;
|
|
12
|
-
move(points: [Point, Point], pinchAround: Point | null, e: TouchEvent): void;
|
|
13
|
-
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
14
|
-
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
15
|
-
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
16
|
-
touchcancel(): void;
|
|
17
|
-
enable(options?: {
|
|
18
|
-
around?: 'center';
|
|
19
|
-
}): void;
|
|
20
|
-
disable(): void;
|
|
21
|
-
isEnabled(): boolean;
|
|
22
|
-
isActive(): boolean;
|
|
23
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
import DOM from '../../utils/dom';
|
|
6
|
-
|
|
7
|
-
var TwoTouchHandler = function () {
|
|
8
|
-
function TwoTouchHandler() {
|
|
9
|
-
_classCallCheck(this, TwoTouchHandler);
|
|
10
|
-
|
|
11
|
-
_defineProperty(this, "enabled", void 0);
|
|
12
|
-
|
|
13
|
-
_defineProperty(this, "active", void 0);
|
|
14
|
-
|
|
15
|
-
_defineProperty(this, "firstTwoTouches", void 0);
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "vector", void 0);
|
|
18
|
-
|
|
19
|
-
_defineProperty(this, "startVector", void 0);
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "aroundCenter", void 0);
|
|
22
|
-
|
|
23
|
-
this.reset();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_createClass(TwoTouchHandler, [{
|
|
27
|
-
key: "reset",
|
|
28
|
-
value: function reset() {
|
|
29
|
-
this.active = false;
|
|
30
|
-
delete this.firstTwoTouches;
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
key: "start",
|
|
34
|
-
value: function start(points) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
key: "move",
|
|
39
|
-
value: function move(points, pinchAround, e) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "touchstart",
|
|
44
|
-
value: function touchstart(e, points, mapTouches) {
|
|
45
|
-
if (this.firstTwoTouches || mapTouches.length < 2) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
50
|
-
this.start([points[0], points[1]]);
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "touchmove",
|
|
54
|
-
value: function touchmove(e, points, mapTouches) {
|
|
55
|
-
if (!this.firstTwoTouches) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
|
|
61
|
-
var _this$firstTwoTouches = _slicedToArray(this.firstTwoTouches, 2),
|
|
62
|
-
idA = _this$firstTwoTouches[0],
|
|
63
|
-
idB = _this$firstTwoTouches[1];
|
|
64
|
-
|
|
65
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
66
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
67
|
-
|
|
68
|
-
if (!a || !b) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
73
|
-
return this.move([a, b], pinchAround, e);
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "touchend",
|
|
77
|
-
value: function touchend(e, points, mapTouches) {
|
|
78
|
-
if (!this.firstTwoTouches) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var _this$firstTwoTouches2 = _slicedToArray(this.firstTwoTouches, 2),
|
|
83
|
-
idA = _this$firstTwoTouches2[0],
|
|
84
|
-
idB = _this$firstTwoTouches2[1];
|
|
85
|
-
|
|
86
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
87
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
88
|
-
|
|
89
|
-
if (a && b) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (this.active) {
|
|
94
|
-
DOM.suppressClick();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.reset();
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "touchcancel",
|
|
101
|
-
value: function touchcancel() {
|
|
102
|
-
this.reset();
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "enable",
|
|
106
|
-
value: function enable(options) {
|
|
107
|
-
this.enabled = true;
|
|
108
|
-
this.aroundCenter = !!options && options.around === 'center';
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "disable",
|
|
112
|
-
value: function disable() {
|
|
113
|
-
this.enabled = false;
|
|
114
|
-
this.reset();
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "isEnabled",
|
|
118
|
-
value: function isEnabled() {
|
|
119
|
-
return this.enabled;
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "isActive",
|
|
123
|
-
value: function isActive() {
|
|
124
|
-
return this.active;
|
|
125
|
-
}
|
|
126
|
-
}]);
|
|
127
|
-
|
|
128
|
-
return TwoTouchHandler;
|
|
129
|
-
}();
|
|
130
|
-
|
|
131
|
-
export { TwoTouchHandler as default };
|
|
132
|
-
|
|
133
|
-
function getTouchById(mapTouches, points, identifier) {
|
|
134
|
-
for (var i = 0; i < mapTouches.length; i++) {
|
|
135
|
-
if (mapTouches[i].identifier === identifier) {
|
|
136
|
-
return points[i];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=two_touch.js.map
|