@antv/l7-map 2.9.37-alpha.2 → 2.9.37-alpha.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.
Files changed (168) hide show
  1. package/es/camera.d.ts +84 -0
  2. package/es/camera.js +767 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +422 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +118 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +81 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +167 -0
  12. package/es/geo/mercator.d.ts +28 -0
  13. package/es/geo/mercator.js +91 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +231 -0
  16. package/es/geo/simple.d.ts +29 -0
  17. package/es/geo/simple.js +92 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +971 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +83 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +200 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +59 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +12 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +75 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +105 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +61 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +39 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +184 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +684 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +10 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +162 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +131 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +131 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +54 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +56 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +56 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +12 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +353 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +72 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +96 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +80 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +130 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +120 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +114 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +62 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +115 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +128 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +110 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +88 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +67 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +138 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +156 -0
  94. package/es/index.d.ts +3 -0
  95. package/es/index.js +3 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +464 -0
  100. package/es/util.d.ts +18 -0
  101. package/es/util.js +84 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +133 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +218 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +45 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +106 -0
  112. package/lib/camera.js +793 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +445 -0
  115. package/lib/geo/edge_insets.js +129 -0
  116. package/lib/geo/lng_lat.js +94 -0
  117. package/lib/geo/lng_lat_bounds.js +177 -0
  118. package/lib/geo/mercator.js +120 -0
  119. package/lib/geo/point.js +239 -0
  120. package/lib/geo/simple.js +123 -0
  121. package/lib/geo/transform.js +1013 -0
  122. package/lib/handler/IHandler.js +5 -0
  123. package/lib/handler/blockable_map_event.js +92 -0
  124. package/lib/handler/box_zoom.js +217 -0
  125. package/lib/handler/click_zoom.js +67 -0
  126. package/lib/handler/events/event.js +23 -0
  127. package/lib/handler/events/index.js +31 -0
  128. package/lib/handler/events/map_mouse_event.js +87 -0
  129. package/lib/handler/events/map_touch_event.js +119 -0
  130. package/lib/handler/events/map_wheel_event.js +72 -0
  131. package/lib/handler/events/render_event.js +52 -0
  132. package/lib/handler/handler_inertia.js +193 -0
  133. package/lib/handler/handler_manager.js +714 -0
  134. package/lib/handler/handler_util.js +17 -0
  135. package/lib/handler/keyboard.js +172 -0
  136. package/lib/handler/map_event.js +140 -0
  137. package/lib/handler/mouse/index.js +31 -0
  138. package/lib/handler/mouse/mouse_handler.js +141 -0
  139. package/lib/handler/mouse/mousepan_handler.js +66 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +67 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +67 -0
  142. package/lib/handler/mouse/util.js +26 -0
  143. package/lib/handler/scroll_zoom.js +367 -0
  144. package/lib/handler/shim/dblclick_zoom.js +80 -0
  145. package/lib/handler/shim/drag_pan.js +105 -0
  146. package/lib/handler/shim/drag_rotate.js +88 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +139 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +131 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +124 -0
  150. package/lib/handler/tap/tap_recognizer.js +78 -0
  151. package/lib/handler/tap/tap_zoom.js +124 -0
  152. package/lib/handler/touch/index.js +39 -0
  153. package/lib/handler/touch/touch_pan.js +138 -0
  154. package/lib/handler/touch/touch_pitch.js +120 -0
  155. package/lib/handler/touch/touch_rotate.js +99 -0
  156. package/lib/handler/touch/touch_zoom.js +78 -0
  157. package/lib/handler/touch/two_touch.js +148 -0
  158. package/lib/hash.js +169 -0
  159. package/lib/index.js +44 -0
  160. package/lib/interface.js +5 -0
  161. package/lib/map.js +489 -0
  162. package/lib/util.js +116 -0
  163. package/lib/utils/Aabb.js +143 -0
  164. package/lib/utils/dom.js +233 -0
  165. package/lib/utils/performance.js +72 -0
  166. package/lib/utils/primitives.js +57 -0
  167. package/lib/utils/task_queue.js +115 -0
  168. package/package.json +3 -3
@@ -0,0 +1,105 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+
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
+
11
+ // @ts-ignore
12
+ import Point from "../../geo/point";
13
+ import DOM from "../../utils/dom";
14
+ import { Event } from "./event";
15
+
16
+ var MapTouchEvent = /*#__PURE__*/function (_Event) {
17
+ _inherits(MapTouchEvent, _Event);
18
+
19
+ var _super = _createSuper(MapTouchEvent);
20
+
21
+ /**
22
+ * The event type.
23
+ */
24
+
25
+ /**
26
+ * The `Map` object that fired the event.
27
+ */
28
+
29
+ /**
30
+ * The DOM event which caused the map event.
31
+ */
32
+
33
+ /**
34
+ * The geographic location on the map of the center of the touch event points.
35
+ */
36
+
37
+ /**
38
+ * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
39
+ * corner.
40
+ */
41
+
42
+ /**
43
+ * The array of pixel coordinates corresponding to a
44
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
45
+ */
46
+
47
+ /**
48
+ * The geographical locations on the map corresponding to a
49
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
50
+ */
51
+
52
+ /**
53
+ * `true` if `preventDefault` has been called.
54
+ * @private
55
+ */
56
+
57
+ /**
58
+ * @private
59
+ */
60
+ function MapTouchEvent(type, map, originalEvent) {
61
+ var _this;
62
+
63
+ _classCallCheck(this, MapTouchEvent);
64
+
65
+ var touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
66
+ var points = DOM.touchPos(map.getCanvasContainer(), touches);
67
+ var lngLats = points.map(function (t) {
68
+ return map.unproject(t);
69
+ });
70
+ var point = points.reduce(function (prev, curr, i, arr) {
71
+ return prev.add(curr.div(arr.length));
72
+ }, new Point(0, 0));
73
+ var lngLat = map.unproject(point);
74
+ _this = _super.call(this, type, {
75
+ points: points,
76
+ point: point,
77
+ lngLats: lngLats,
78
+ lngLat: lngLat,
79
+ originalEvent: originalEvent
80
+ });
81
+ _this.defaultPrevented = false;
82
+ return _this;
83
+ }
84
+ /**
85
+ * Prevents subsequent default processing of the event by the map.
86
+ *
87
+ * Calling this method will prevent the following default map behaviors:
88
+ *
89
+ * * On `touchstart` events, the behavior of {@link DragPanHandler}
90
+ * * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
91
+ *
92
+ */
93
+
94
+
95
+ _createClass(MapTouchEvent, [{
96
+ key: "preventDefault",
97
+ value: function preventDefault() {
98
+ this.defaultPrevented = true;
99
+ }
100
+ }]);
101
+
102
+ return MapTouchEvent;
103
+ }(Event);
104
+
105
+ export { MapTouchEvent as default };
@@ -0,0 +1,33 @@
1
+ import { EarthMap } from '../../earthmap';
2
+ import { Map } from '../../map';
3
+ import { Event } from './event';
4
+ export interface IMapBoxZoomEvent {
5
+ type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';
6
+ target: Map | EarthMap;
7
+ originalEvent: MouseEvent;
8
+ }
9
+ export default class MapWheelEvent extends Event {
10
+ /**
11
+ * The event type.
12
+ */
13
+ type: 'wheel';
14
+ /**
15
+ * The DOM event which caused the map event.
16
+ */
17
+ originalEvent: WheelEvent;
18
+ defaultPrevented: boolean;
19
+ /**
20
+ * The `Map` object that fired the event.
21
+ */
22
+ target: Map | EarthMap;
23
+ /**
24
+ * @private
25
+ */
26
+ constructor(type: string, map: Map | EarthMap, originalEvent: WheelEvent);
27
+ /**
28
+ * Prevents subsequent default processing of the event by the map.
29
+ *
30
+ * Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
31
+ */
32
+ private preventDefault;
33
+ }
@@ -0,0 +1,61 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+
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
+
11
+ import { Event } from "./event";
12
+
13
+ var MapWheelEvent = /*#__PURE__*/function (_Event) {
14
+ _inherits(MapWheelEvent, _Event);
15
+
16
+ var _super = _createSuper(MapWheelEvent);
17
+
18
+ /**
19
+ * The event type.
20
+ */
21
+
22
+ /**
23
+ * The DOM event which caused the map event.
24
+ */
25
+
26
+ /**
27
+ * The `Map` object that fired the event.
28
+ */
29
+
30
+ /**
31
+ * @private
32
+ */
33
+ function MapWheelEvent(type, map, originalEvent) {
34
+ var _this;
35
+
36
+ _classCallCheck(this, MapWheelEvent);
37
+
38
+ _this = _super.call(this, type, {
39
+ originalEvent: originalEvent
40
+ });
41
+ _this.defaultPrevented = false;
42
+ return _this;
43
+ }
44
+ /**
45
+ * Prevents subsequent default processing of the event by the map.
46
+ *
47
+ * Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
48
+ */
49
+
50
+
51
+ _createClass(MapWheelEvent, [{
52
+ key: "preventDefault",
53
+ value: function preventDefault() {
54
+ this.defaultPrevented = true;
55
+ }
56
+ }]);
57
+
58
+ return MapWheelEvent;
59
+ }(Event);
60
+
61
+ export { MapWheelEvent as default };
@@ -0,0 +1,5 @@
1
+ import { Event } from './event';
2
+ export default class RenderFrameEvent extends Event {
3
+ type: string;
4
+ timeStamp: number;
5
+ }
@@ -0,0 +1,39 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+
9
+ 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); }; }
10
+
11
+ 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; } }
12
+
13
+ import { Event } from "./event";
14
+
15
+ var RenderFrameEvent = /*#__PURE__*/function (_Event) {
16
+ _inherits(RenderFrameEvent, _Event);
17
+
18
+ var _super = _createSuper(RenderFrameEvent);
19
+
20
+ function RenderFrameEvent() {
21
+ var _this;
22
+
23
+ _classCallCheck(this, RenderFrameEvent);
24
+
25
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ args[_key] = arguments[_key];
27
+ }
28
+
29
+ _this = _super.call.apply(_super, [this].concat(args));
30
+
31
+ _defineProperty(_assertThisInitialized(_this), "type", 'renderFrame');
32
+
33
+ return _this;
34
+ }
35
+
36
+ return _createClass(RenderFrameEvent);
37
+ }(Event);
38
+
39
+ export { RenderFrameEvent as default };
@@ -0,0 +1,23 @@
1
+ import { EarthMap } from '../earthmap';
2
+ import { Map } from '../map';
3
+ import { IDragPanOptions } from './shim/drag_pan';
4
+ export interface IInertiaOptions {
5
+ linearity: number;
6
+ easing: (t: number) => number;
7
+ deceleration: number;
8
+ maxSpeed: number;
9
+ }
10
+ export declare type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;
11
+ export default class HandlerInertia {
12
+ private map;
13
+ private inertiaBuffer;
14
+ constructor(map: Map | EarthMap);
15
+ clear(): void;
16
+ record(settings: any): void;
17
+ drainInertiaBuffer(): void;
18
+ onMoveEnd(panInertiaOptions?: IDragPanOptions): ({
19
+ [key: string]: any;
20
+ } & {
21
+ noMoveStart: boolean;
22
+ }) | undefined;
23
+ }
@@ -0,0 +1,184 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+
4
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
+
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
9
+
10
+ // @ts-ignore
11
+ import Point from "../geo/point"; // tslint:disable-next-line:no-submodule-imports
12
+
13
+ import merge from 'lodash/merge';
14
+ import { bezier, clamp, now } from "../util";
15
+ var defaultInertiaOptions = {
16
+ linearity: 0.3,
17
+ easing: bezier(0, 0, 0.3, 1)
18
+ };
19
+ var defaultPanInertiaOptions = merge({
20
+ deceleration: 2500,
21
+ maxSpeed: 1400
22
+ }, defaultInertiaOptions);
23
+ var defaultZoomInertiaOptions = merge({
24
+ deceleration: 20,
25
+ maxSpeed: 1400
26
+ }, defaultInertiaOptions);
27
+ var defaultBearingInertiaOptions = merge({
28
+ deceleration: 1000,
29
+ maxSpeed: 360
30
+ }, defaultInertiaOptions);
31
+ var defaultPitchInertiaOptions = merge({
32
+ deceleration: 1000,
33
+ maxSpeed: 90
34
+ }, defaultInertiaOptions);
35
+
36
+ var HandlerInertia = /*#__PURE__*/function () {
37
+ function HandlerInertia(map) {
38
+ _classCallCheck(this, HandlerInertia);
39
+
40
+ this.map = map;
41
+ this.clear();
42
+ }
43
+
44
+ _createClass(HandlerInertia, [{
45
+ key: "clear",
46
+ value: function clear() {
47
+ this.inertiaBuffer = [];
48
+ }
49
+ }, {
50
+ key: "record",
51
+ value: function record(settings) {
52
+ this.drainInertiaBuffer();
53
+ this.inertiaBuffer.push({
54
+ time: now(),
55
+ settings: settings
56
+ });
57
+ }
58
+ }, {
59
+ key: "drainInertiaBuffer",
60
+ value: function drainInertiaBuffer() {
61
+ var inertia = this.inertiaBuffer;
62
+ var nowTime = now();
63
+ var cutoff = 160; // msec
64
+
65
+ while (inertia.length > 0 && nowTime - inertia[0].time > cutoff) {
66
+ inertia.shift();
67
+ }
68
+ }
69
+ }, {
70
+ key: "onMoveEnd",
71
+ value: function onMoveEnd(panInertiaOptions) {
72
+ this.drainInertiaBuffer();
73
+
74
+ if (this.inertiaBuffer.length < 2) {
75
+ return;
76
+ }
77
+
78
+ var deltas = {
79
+ zoom: 0,
80
+ bearing: 0,
81
+ pitch: 0,
82
+ pan: new Point(0, 0),
83
+ pinchAround: undefined,
84
+ around: undefined
85
+ };
86
+
87
+ var _iterator = _createForOfIteratorHelper(this.inertiaBuffer),
88
+ _step;
89
+
90
+ try {
91
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
92
+ var settings = _step.value.settings;
93
+ deltas.zoom += settings.zoomDelta || 0;
94
+ deltas.bearing += settings.bearingDelta || 0;
95
+ deltas.pitch += settings.pitchDelta || 0;
96
+
97
+ if (settings.panDelta) {
98
+ deltas.pan._add(settings.panDelta);
99
+ }
100
+
101
+ if (settings.around) {
102
+ deltas.around = settings.around;
103
+ }
104
+
105
+ if (settings.pinchAround) {
106
+ deltas.pinchAround = settings.pinchAround;
107
+ }
108
+ }
109
+ } catch (err) {
110
+ _iterator.e(err);
111
+ } finally {
112
+ _iterator.f();
113
+ }
114
+
115
+ var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
116
+ var duration = lastEntry.time - this.inertiaBuffer[0].time;
117
+ var easeOptions = {};
118
+
119
+ if (deltas.pan.mag()) {
120
+ var result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
121
+ easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
122
+ easeOptions.center = this.map.transform.center;
123
+ extendDuration(easeOptions, result);
124
+ }
125
+
126
+ if (deltas.zoom) {
127
+ var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
128
+
129
+ easeOptions.zoom = this.map.transform.zoom + _result.amount;
130
+ extendDuration(easeOptions, _result);
131
+ }
132
+
133
+ if (deltas.bearing) {
134
+ var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
135
+
136
+ easeOptions.bearing = this.map.transform.bearing + clamp(_result2.amount, -179, 179);
137
+ extendDuration(easeOptions, _result2);
138
+ }
139
+
140
+ if (deltas.pitch) {
141
+ var _result3 = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
142
+
143
+ easeOptions.pitch = this.map.transform.pitch + _result3.amount;
144
+ extendDuration(easeOptions, _result3);
145
+ }
146
+
147
+ if (easeOptions.zoom || easeOptions.bearing) {
148
+ var last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
149
+ easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
150
+ }
151
+
152
+ this.clear();
153
+ return merge(easeOptions, {
154
+ noMoveStart: true
155
+ });
156
+ }
157
+ }]);
158
+
159
+ return HandlerInertia;
160
+ }(); // Unfortunately zoom, bearing, etc can't have different durations and easings so
161
+ // we need to choose one. We use the longest duration and it's corresponding easing.
162
+
163
+
164
+ export { HandlerInertia as default };
165
+
166
+ function extendDuration(easeOptions, result) {
167
+ if (!easeOptions.duration || easeOptions.duration < result.duration) {
168
+ easeOptions.duration = result.duration;
169
+ easeOptions.easing = result.easing;
170
+ }
171
+ }
172
+
173
+ function calculateEasing(amount, inertiaDuration, inertiaOptions) {
174
+ var maxSpeed = inertiaOptions.maxSpeed,
175
+ linearity = inertiaOptions.linearity,
176
+ deceleration = inertiaOptions.deceleration;
177
+ var speed = clamp(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
178
+ var duration = Math.abs(speed) / (deceleration * linearity);
179
+ return {
180
+ easing: inertiaOptions.easing,
181
+ duration: duration * 1000,
182
+ amount: speed * (duration / 2)
183
+ };
184
+ }
@@ -0,0 +1,61 @@
1
+ import { EarthMap } from '../earthmap';
2
+ import { Map } from '../map';
3
+ import RenderFrameEvent from './events/render_event';
4
+ import { IHandlerResult } from './IHandler';
5
+ export declare type InputEvent = MouseEvent | TouchEvent | KeyboardEvent | WheelEvent;
6
+ export interface IHandlerOptions {
7
+ interactive: boolean;
8
+ boxZoom: boolean;
9
+ dragRotate: boolean;
10
+ dragPan: boolean;
11
+ keyboard: boolean;
12
+ doubleClickZoom: boolean;
13
+ touchZoomRotate: boolean;
14
+ touchPitch: boolean;
15
+ trackResize: boolean;
16
+ renderWorldCopies: boolean;
17
+ bearingSnap: number;
18
+ clickTolerance: number;
19
+ pitchWithRotate: boolean;
20
+ pitchEnabled: boolean;
21
+ rotateEnabled: boolean;
22
+ }
23
+ declare class HandlerManager {
24
+ private map;
25
+ private el;
26
+ private handlers;
27
+ private eventsInProgress;
28
+ private frameId;
29
+ private inertia;
30
+ private bearingSnap;
31
+ private handlersById;
32
+ private updatingCamera;
33
+ private changes;
34
+ private previousActiveHandlers;
35
+ private bearingChanged;
36
+ private rotateEnabled;
37
+ private pitchEnabled;
38
+ private listeners;
39
+ constructor(map: Map | EarthMap, options: IHandlerOptions);
40
+ destroy(): void;
41
+ stop(): void;
42
+ isActive(): boolean;
43
+ isZooming(): boolean;
44
+ isRotating(): boolean;
45
+ isMoving(): boolean;
46
+ handleWindowEvent: (e: InputEvent) => void;
47
+ handleEvent: (e: InputEvent | RenderFrameEvent, eventName?: string) => void;
48
+ mergeIHandlerResult(mergedIHandlerResult: IHandlerResult, eventsInProgress: {
49
+ [key: string]: any;
50
+ }, HandlerResult: IHandlerResult, name: string, e?: InputEvent): void;
51
+ triggerRenderFrame(): void;
52
+ private addDefaultHandlers;
53
+ private add;
54
+ private blockedByActive;
55
+ private getMapTouches;
56
+ private applyChanges;
57
+ private updateMapTransform;
58
+ private fireEvents;
59
+ private fireEvent;
60
+ }
61
+ export default HandlerManager;