@antv/l7-map 2.21.1 → 2.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/camera.js +595 -674
- package/es/earthmap.js +313 -276
- package/es/geo/edge_insets.js +57 -72
- package/es/geo/lng_lat.js +50 -64
- package/es/geo/lng_lat_bounds.js +101 -137
- package/es/geo/mercator.js +23 -35
- package/es/geo/point.js +150 -221
- package/es/geo/simple.js +22 -34
- package/es/geo/transform.js +839 -905
- package/es/handler/blockable_map_event.js +46 -66
- package/es/handler/box_zoom.js +125 -143
- package/es/handler/click_zoom.js +37 -51
- package/es/handler/events/event.js +11 -9
- package/es/handler/events/map_mouse_event.js +39 -54
- package/es/handler/events/map_touch_event.js +54 -73
- package/es/handler/events/map_wheel_event.js +22 -38
- package/es/handler/events/render_event.js +6 -23
- package/es/handler/handler_inertia.js +98 -113
- package/es/handler/handler_manager.js +349 -437
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +98 -110
- package/es/handler/map_event.js +81 -117
- package/es/handler/mouse/mouse_handler.js +81 -100
- package/es/handler/mouse/mousepan_handler.js +16 -39
- package/es/handler/mouse/mousepitch_hander.js +18 -40
- package/es/handler/mouse/mouserotate_hander.js +18 -40
- package/es/handler/mouse/util.js +7 -5
- package/es/handler/scroll_zoom.js +221 -231
- package/es/handler/shim/dblclick_zoom.js +36 -47
- package/es/handler/shim/drag_pan.js +41 -50
- package/es/handler/shim/drag_rotate.js +38 -48
- package/es/handler/shim/touch_zoom_rotate.js +68 -79
- package/es/handler/tap/single_tap_recognizer.js +60 -80
- package/es/handler/tap/tap_drag_zoom.js +72 -89
- package/es/handler/tap/tap_recognizer.js +37 -45
- package/es/handler/tap/tap_zoom.js +67 -95
- package/es/handler/touch/touch_pan.js +77 -96
- package/es/handler/touch/touch_pitch.js +61 -79
- package/es/handler/touch/touch_rotate.js +47 -67
- package/es/handler/touch/touch_zoom.js +29 -46
- package/es/handler/touch/two_touch.js +79 -104
- package/es/hash.js +75 -88
- package/es/map.js +318 -284
- package/es/util.js +18 -37
- package/es/utils/Aabb.js +60 -100
- package/es/utils/dom.js +32 -55
- package/es/utils/performance.js +25 -29
- package/es/utils/primitives.js +33 -42
- package/es/utils/task_queue.js +47 -76
- package/lib/camera.d.ts +86 -0
- package/lib/camera.js +597 -672
- package/lib/earthmap.d.ts +69 -0
- package/lib/earthmap.js +314 -276
- package/lib/geo/edge_insets.d.ts +54 -0
- package/lib/geo/edge_insets.js +58 -70
- package/lib/geo/lng_lat.d.ts +18 -0
- package/lib/geo/lng_lat.js +50 -62
- package/lib/geo/lng_lat_bounds.d.ts +25 -0
- package/lib/geo/lng_lat_bounds.js +102 -136
- package/lib/geo/mercator.d.ts +30 -0
- package/lib/geo/mercator.js +26 -37
- package/lib/geo/point.d.ts +40 -0
- package/lib/geo/point.js +151 -220
- package/lib/geo/simple.d.ts +30 -0
- package/lib/geo/simple.js +25 -36
- package/lib/geo/transform.d.ts +198 -0
- package/lib/geo/transform.js +844 -907
- package/lib/handler/IHandler.d.ts +34 -0
- package/lib/handler/blockable_map_event.d.ts +17 -0
- package/lib/handler/blockable_map_event.js +48 -65
- package/lib/handler/box_zoom.d.ts +59 -0
- package/lib/handler/box_zoom.js +126 -143
- package/lib/handler/click_zoom.d.ts +16 -0
- package/lib/handler/click_zoom.js +38 -50
- package/lib/handler/events/event.d.ts +4 -0
- package/lib/handler/events/event.js +12 -9
- package/lib/handler/events/index.d.ts +4 -0
- package/lib/handler/events/index.js +3 -3
- package/lib/handler/events/map_mouse_event.d.ts +34 -0
- package/lib/handler/events/map_mouse_event.js +41 -52
- package/lib/handler/events/map_touch_event.d.ts +57 -0
- package/lib/handler/events/map_touch_event.js +56 -71
- package/lib/handler/events/map_wheel_event.d.ts +33 -0
- package/lib/handler/events/map_wheel_event.js +23 -37
- package/lib/handler/events/render_event.d.ts +5 -0
- package/lib/handler/events/render_event.js +7 -22
- package/lib/handler/handler_inertia.d.ts +23 -0
- package/lib/handler/handler_inertia.js +102 -112
- package/lib/handler/handler_manager.d.ts +61 -0
- package/lib/handler/handler_manager.js +351 -437
- package/lib/handler/handler_util.d.ts +4 -0
- package/lib/handler/handler_util.js +2 -2
- package/lib/handler/keyboard.d.ts +36 -0
- package/lib/handler/keyboard.js +98 -110
- package/lib/handler/map_event.d.ts +29 -0
- package/lib/handler/map_event.js +83 -116
- package/lib/handler/mouse/index.d.ts +4 -0
- package/lib/handler/mouse/index.js +3 -3
- package/lib/handler/mouse/mouse_handler.d.ts +22 -0
- package/lib/handler/mouse/mouse_handler.js +83 -99
- package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
- package/lib/handler/mouse/mousepan_handler.js +19 -38
- package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/lib/handler/mouse/mousepitch_hander.js +21 -39
- package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/lib/handler/mouse/mouserotate_hander.js +21 -39
- package/lib/handler/mouse/util.d.ts +6 -0
- package/lib/handler/mouse/util.js +7 -6
- package/lib/handler/scroll_zoom.d.ts +93 -0
- package/lib/handler/scroll_zoom.js +221 -231
- package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
- package/lib/handler/shim/dblclick_zoom.js +37 -46
- package/lib/handler/shim/drag_pan.d.ts +61 -0
- package/lib/handler/shim/drag_pan.js +42 -49
- package/lib/handler/shim/drag_rotate.d.ts +46 -0
- package/lib/handler/shim/drag_rotate.js +39 -47
- package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/lib/handler/shim/touch_zoom_rotate.js +69 -78
- package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/lib/handler/tap/single_tap_recognizer.js +63 -79
- package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_drag_zoom.js +74 -88
- package/lib/handler/tap/tap_recognizer.d.ts +17 -0
- package/lib/handler/tap/tap_recognizer.js +41 -47
- package/lib/handler/tap/tap_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_zoom.js +69 -94
- package/lib/handler/touch/index.d.ts +5 -0
- package/lib/handler/touch/index.js +4 -4
- package/lib/handler/touch/touch_pan.d.ts +30 -0
- package/lib/handler/touch/touch_pan.js +79 -95
- package/lib/handler/touch/touch_pitch.d.ts +13 -0
- package/lib/handler/touch/touch_pitch.js +64 -78
- package/lib/handler/touch/touch_rotate.d.ts +12 -0
- package/lib/handler/touch/touch_rotate.js +50 -66
- package/lib/handler/touch/touch_zoom.d.ts +12 -0
- package/lib/handler/touch/touch_zoom.js +32 -45
- package/lib/handler/touch/two_touch.d.ts +23 -0
- package/lib/handler/touch/two_touch.js +81 -103
- package/lib/hash.d.ts +14 -0
- package/lib/hash.js +75 -88
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -4
- package/lib/interface.d.ts +34 -0
- package/lib/map.d.ts +70 -0
- package/lib/map.js +319 -284
- package/lib/util.d.ts +25 -0
- package/lib/util.js +20 -36
- package/lib/utils/Aabb.d.ts +12 -0
- package/lib/utils/Aabb.js +61 -99
- package/lib/utils/dom.d.ts +4 -0
- package/lib/utils/dom.js +34 -55
- package/lib/utils/performance.d.ts +17 -0
- package/lib/utils/performance.js +25 -29
- package/lib/utils/primitives.d.ts +6 -0
- package/lib/utils/primitives.js +34 -41
- package/lib/utils/task_queue.d.ts +13 -0
- package/lib/utils/task_queue.js +47 -76
- package/package.json +25 -32
|
@@ -1,78 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
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); }; }
|
|
7
|
-
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; } }
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
2
|
// @ts-ignore
|
|
9
3
|
|
|
10
4
|
import Point from "../../geo/point";
|
|
11
5
|
import DOM from "../../utils/dom";
|
|
12
6
|
import { Event } from "./event";
|
|
13
|
-
|
|
14
|
-
_inherits(MapTouchEvent, _Event);
|
|
15
|
-
var _super = _createSuper(MapTouchEvent);
|
|
7
|
+
export default class MapTouchEvent extends Event {
|
|
16
8
|
/**
|
|
17
|
-
* The event type.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The `Map` object that fired the event.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The DOM event which caused the map event.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The geographic location on the map of the center of the touch event points.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
|
|
34
|
-
* corner.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The array of pixel coordinates corresponding to a
|
|
39
|
-
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The geographical locations on the map corresponding to a
|
|
44
|
-
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* `true` if `preventDefault` has been called.
|
|
49
9
|
* @private
|
|
50
10
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _this;
|
|
57
|
-
_classCallCheck(this, MapTouchEvent);
|
|
58
|
-
var touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
|
|
59
|
-
var points = DOM.touchPos(map.getCanvasContainer(), touches);
|
|
60
|
-
var lngLats = points.map(function (t) {
|
|
61
|
-
return map.unproject(t);
|
|
62
|
-
});
|
|
63
|
-
var point = points.reduce(function (prev, curr, i, arr) {
|
|
11
|
+
constructor(type, map, originalEvent) {
|
|
12
|
+
const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
|
|
13
|
+
const points = DOM.touchPos(map.getCanvasContainer(), touches);
|
|
14
|
+
const lngLats = points.map(t => map.unproject(t));
|
|
15
|
+
const point = points.reduce((prev, curr, i, arr) => {
|
|
64
16
|
return prev.add(curr.div(arr.length));
|
|
65
17
|
}, new Point(0, 0));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
points
|
|
69
|
-
point
|
|
70
|
-
lngLats
|
|
71
|
-
lngLat
|
|
72
|
-
originalEvent
|
|
18
|
+
const lngLat = map.unproject(point);
|
|
19
|
+
super(type, {
|
|
20
|
+
points,
|
|
21
|
+
point,
|
|
22
|
+
lngLats,
|
|
23
|
+
lngLat,
|
|
24
|
+
originalEvent
|
|
73
25
|
});
|
|
74
|
-
|
|
75
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The event type.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* The `Map` object that fired the event.
|
|
31
|
+
*/
|
|
32
|
+
_defineProperty(this, "target", void 0);
|
|
33
|
+
/**
|
|
34
|
+
* The DOM event which caused the map event.
|
|
35
|
+
*/
|
|
36
|
+
_defineProperty(this, "originalEvent", void 0);
|
|
37
|
+
/**
|
|
38
|
+
* The geographic location on the map of the center of the touch event points.
|
|
39
|
+
*/
|
|
40
|
+
_defineProperty(this, "lngLat", void 0);
|
|
41
|
+
/**
|
|
42
|
+
* The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
|
|
43
|
+
* corner.
|
|
44
|
+
*/
|
|
45
|
+
_defineProperty(this, "point", void 0);
|
|
46
|
+
/**
|
|
47
|
+
* The array of pixel coordinates corresponding to a
|
|
48
|
+
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
49
|
+
*/
|
|
50
|
+
_defineProperty(this, "points", void 0);
|
|
51
|
+
/**
|
|
52
|
+
* The geographical locations on the map corresponding to a
|
|
53
|
+
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
54
|
+
*/
|
|
55
|
+
_defineProperty(this, "lngLats", void 0);
|
|
56
|
+
/**
|
|
57
|
+
* `true` if `preventDefault` has been called.
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
_defineProperty(this, "defaultPrevented", void 0);
|
|
61
|
+
this.defaultPrevented = false;
|
|
76
62
|
}
|
|
77
63
|
|
|
78
64
|
/**
|
|
@@ -84,12 +70,7 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
|
|
|
84
70
|
* * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
|
|
85
71
|
*
|
|
86
72
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}]);
|
|
93
|
-
return MapTouchEvent;
|
|
94
|
-
}(Event);
|
|
95
|
-
export { MapTouchEvent as default };
|
|
73
|
+
preventDefault() {
|
|
74
|
+
this.defaultPrevented = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
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); }; }
|
|
7
|
-
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; } }
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
2
|
import { Event } from "./event";
|
|
9
|
-
|
|
10
|
-
_inherits(MapWheelEvent, _Event);
|
|
11
|
-
var _super = _createSuper(MapWheelEvent);
|
|
12
|
-
/**
|
|
13
|
-
* The event type.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The DOM event which caused the map event.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The `Map` object that fired the event.
|
|
22
|
-
*/
|
|
23
|
-
|
|
3
|
+
export default class MapWheelEvent extends Event {
|
|
24
4
|
/**
|
|
25
5
|
* @private
|
|
26
6
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_this = _super.call(this, type, {
|
|
31
|
-
originalEvent: originalEvent
|
|
7
|
+
constructor(type, map, originalEvent) {
|
|
8
|
+
super(type, {
|
|
9
|
+
originalEvent
|
|
32
10
|
});
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The event type.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The DOM event which caused the map event.
|
|
16
|
+
*/
|
|
17
|
+
_defineProperty(this, "originalEvent", void 0);
|
|
18
|
+
_defineProperty(this, "defaultPrevented", void 0);
|
|
19
|
+
/**
|
|
20
|
+
* The `Map` object that fired the event.
|
|
21
|
+
*/
|
|
22
|
+
_defineProperty(this, "target", void 0);
|
|
23
|
+
this.defaultPrevented = false;
|
|
35
24
|
}
|
|
36
25
|
|
|
37
26
|
/**
|
|
@@ -39,12 +28,7 @@ var MapWheelEvent = /*#__PURE__*/function (_Event) {
|
|
|
39
28
|
*
|
|
40
29
|
* Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
|
|
41
30
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}]);
|
|
48
|
-
return MapWheelEvent;
|
|
49
|
-
}(Event);
|
|
50
|
-
export { MapWheelEvent as default };
|
|
31
|
+
preventDefault() {
|
|
32
|
+
this.defaultPrevented = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
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
|
-
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; } }
|
|
10
2
|
import { Event } from "./event";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_classCallCheck(this, RenderFrameEvent);
|
|
17
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
-
args[_key] = arguments[_key];
|
|
19
|
-
}
|
|
20
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
21
|
-
_defineProperty(_assertThisInitialized(_this), "type", 'renderFrame');
|
|
22
|
-
return _this;
|
|
3
|
+
export default class RenderFrameEvent extends Event {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
_defineProperty(this, "type", 'renderFrame');
|
|
7
|
+
_defineProperty(this, "timeStamp", void 0);
|
|
23
8
|
}
|
|
24
|
-
|
|
25
|
-
}(Event);
|
|
26
|
-
export { RenderFrameEvent as default };
|
|
9
|
+
}
|
|
@@ -1,142 +1,125 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
2
|
// @ts-ignore
|
|
7
3
|
import Point from "../geo/point";
|
|
8
4
|
|
|
9
5
|
// tslint:disable-next-line:no-submodule-imports
|
|
10
6
|
import { lodashUtil } from '@antv/l7-utils';
|
|
11
7
|
import { bezier, clamp, now } from "../util";
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const {
|
|
9
|
+
merge
|
|
10
|
+
} = lodashUtil;
|
|
11
|
+
const defaultInertiaOptions = {
|
|
14
12
|
linearity: 0.3,
|
|
15
13
|
easing: bezier(0, 0, 0.3, 1)
|
|
16
14
|
};
|
|
17
|
-
|
|
15
|
+
const defaultPanInertiaOptions = merge({
|
|
18
16
|
deceleration: 2500,
|
|
19
17
|
maxSpeed: 1400
|
|
20
18
|
}, defaultInertiaOptions);
|
|
21
|
-
|
|
19
|
+
const defaultZoomInertiaOptions = merge({
|
|
22
20
|
deceleration: 20,
|
|
23
21
|
maxSpeed: 1400
|
|
24
22
|
}, defaultInertiaOptions);
|
|
25
|
-
|
|
23
|
+
const defaultBearingInertiaOptions = merge({
|
|
26
24
|
deceleration: 1000,
|
|
27
25
|
maxSpeed: 360
|
|
28
26
|
}, defaultInertiaOptions);
|
|
29
|
-
|
|
27
|
+
const defaultPitchInertiaOptions = merge({
|
|
30
28
|
deceleration: 1000,
|
|
31
29
|
maxSpeed: 90
|
|
32
30
|
}, defaultInertiaOptions);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
export default class HandlerInertia {
|
|
32
|
+
constructor(map) {
|
|
33
|
+
_defineProperty(this, "map", void 0);
|
|
34
|
+
_defineProperty(this, "inertiaBuffer", void 0);
|
|
36
35
|
this.map = map;
|
|
37
36
|
this.clear();
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, {
|
|
54
|
-
key: "drainInertiaBuffer",
|
|
55
|
-
value: function drainInertiaBuffer() {
|
|
56
|
-
var inertia = this.inertiaBuffer;
|
|
57
|
-
var nowTime = now();
|
|
58
|
-
var cutoff = 160; // msec
|
|
38
|
+
clear() {
|
|
39
|
+
this.inertiaBuffer = [];
|
|
40
|
+
}
|
|
41
|
+
record(settings) {
|
|
42
|
+
this.drainInertiaBuffer();
|
|
43
|
+
this.inertiaBuffer.push({
|
|
44
|
+
time: now(),
|
|
45
|
+
settings
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
drainInertiaBuffer() {
|
|
49
|
+
const inertia = this.inertiaBuffer;
|
|
50
|
+
const nowTime = now();
|
|
51
|
+
const cutoff = 160; // msec
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
53
|
+
while (inertia.length > 0 && nowTime - inertia[0].time > cutoff) {
|
|
54
|
+
inertia.shift();
|
|
63
55
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
deltas.pitch += settings.pitchDelta || 0;
|
|
87
|
-
if (settings.panDelta) {
|
|
88
|
-
deltas.pan._add(settings.panDelta);
|
|
89
|
-
}
|
|
90
|
-
if (settings.around) {
|
|
91
|
-
deltas.around = settings.around;
|
|
92
|
-
}
|
|
93
|
-
if (settings.pinchAround) {
|
|
94
|
-
deltas.pinchAround = settings.pinchAround;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
} catch (err) {
|
|
98
|
-
_iterator.e(err);
|
|
99
|
-
} finally {
|
|
100
|
-
_iterator.f();
|
|
101
|
-
}
|
|
102
|
-
var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
|
|
103
|
-
var duration = lastEntry.time - this.inertiaBuffer[0].time;
|
|
104
|
-
var easeOptions = {};
|
|
105
|
-
if (deltas.pan.mag()) {
|
|
106
|
-
var result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
107
|
-
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
108
|
-
easeOptions.center = this.map.transform.center;
|
|
109
|
-
extendDuration(easeOptions, result);
|
|
110
|
-
}
|
|
111
|
-
if (deltas.zoom) {
|
|
112
|
-
var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
113
|
-
easeOptions.zoom = this.map.transform.zoom + _result.amount;
|
|
114
|
-
extendDuration(easeOptions, _result);
|
|
115
|
-
}
|
|
116
|
-
if (deltas.bearing) {
|
|
117
|
-
var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
118
|
-
easeOptions.bearing = this.map.transform.bearing + clamp(_result2.amount, -179, 179);
|
|
119
|
-
extendDuration(easeOptions, _result2);
|
|
56
|
+
}
|
|
57
|
+
onMoveEnd(panInertiaOptions) {
|
|
58
|
+
this.drainInertiaBuffer();
|
|
59
|
+
if (this.inertiaBuffer.length < 2) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const deltas = {
|
|
63
|
+
zoom: 0,
|
|
64
|
+
bearing: 0,
|
|
65
|
+
pitch: 0,
|
|
66
|
+
pan: new Point(0, 0),
|
|
67
|
+
pinchAround: undefined,
|
|
68
|
+
around: undefined
|
|
69
|
+
};
|
|
70
|
+
for (const {
|
|
71
|
+
settings
|
|
72
|
+
} of this.inertiaBuffer) {
|
|
73
|
+
deltas.zoom += settings.zoomDelta || 0;
|
|
74
|
+
deltas.bearing += settings.bearingDelta || 0;
|
|
75
|
+
deltas.pitch += settings.pitchDelta || 0;
|
|
76
|
+
if (settings.panDelta) {
|
|
77
|
+
deltas.pan._add(settings.panDelta);
|
|
120
78
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
easeOptions.pitch = this.map.transform.pitch + _result3.amount;
|
|
124
|
-
extendDuration(easeOptions, _result3);
|
|
79
|
+
if (settings.around) {
|
|
80
|
+
deltas.around = settings.around;
|
|
125
81
|
}
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
82
|
+
if (settings.pinchAround) {
|
|
83
|
+
deltas.pinchAround = settings.pinchAround;
|
|
129
84
|
}
|
|
130
|
-
this.clear();
|
|
131
|
-
return merge(easeOptions, {
|
|
132
|
-
noMoveStart: true
|
|
133
|
-
});
|
|
134
85
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
86
|
+
const lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
|
|
87
|
+
const duration = lastEntry.time - this.inertiaBuffer[0].time;
|
|
88
|
+
const easeOptions = {};
|
|
89
|
+
if (deltas.pan.mag()) {
|
|
90
|
+
const result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
91
|
+
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
92
|
+
easeOptions.center = this.map.transform.center;
|
|
93
|
+
extendDuration(easeOptions, result);
|
|
94
|
+
}
|
|
95
|
+
if (deltas.zoom) {
|
|
96
|
+
const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
97
|
+
easeOptions.zoom = this.map.transform.zoom + result.amount;
|
|
98
|
+
extendDuration(easeOptions, result);
|
|
99
|
+
}
|
|
100
|
+
if (deltas.bearing) {
|
|
101
|
+
const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
102
|
+
easeOptions.bearing = this.map.transform.bearing + clamp(result.amount, -179, 179);
|
|
103
|
+
extendDuration(easeOptions, result);
|
|
104
|
+
}
|
|
105
|
+
if (deltas.pitch) {
|
|
106
|
+
const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
107
|
+
easeOptions.pitch = this.map.transform.pitch + result.amount;
|
|
108
|
+
extendDuration(easeOptions, result);
|
|
109
|
+
}
|
|
110
|
+
if (easeOptions.zoom || easeOptions.bearing) {
|
|
111
|
+
const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
112
|
+
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
113
|
+
}
|
|
114
|
+
this.clear();
|
|
115
|
+
return merge(easeOptions, {
|
|
116
|
+
noMoveStart: true
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Unfortunately zoom, bearing, etc can't have different durations and easings so
|
|
138
122
|
// we need to choose one. We use the longest duration and it's corresponding easing.
|
|
139
|
-
export { HandlerInertia as default };
|
|
140
123
|
function extendDuration(easeOptions, result) {
|
|
141
124
|
if (!easeOptions.duration || easeOptions.duration < result.duration) {
|
|
142
125
|
easeOptions.duration = result.duration;
|
|
@@ -144,11 +127,13 @@ function extendDuration(easeOptions, result) {
|
|
|
144
127
|
}
|
|
145
128
|
}
|
|
146
129
|
function calculateEasing(amount, inertiaDuration, inertiaOptions) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
130
|
+
const {
|
|
131
|
+
maxSpeed,
|
|
132
|
+
linearity,
|
|
133
|
+
deceleration
|
|
134
|
+
} = inertiaOptions;
|
|
135
|
+
const speed = clamp(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
|
|
136
|
+
const duration = Math.abs(speed) / (deceleration * linearity);
|
|
152
137
|
return {
|
|
153
138
|
easing: inertiaOptions.easing,
|
|
154
139
|
duration: duration * 1000,
|