@antv/l7-map 2.21.1 → 2.21.2

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 (158) hide show
  1. package/es/camera.js +595 -674
  2. package/es/earthmap.js +313 -276
  3. package/es/geo/edge_insets.js +57 -72
  4. package/es/geo/lng_lat.js +50 -64
  5. package/es/geo/lng_lat_bounds.js +101 -137
  6. package/es/geo/mercator.js +23 -35
  7. package/es/geo/point.js +150 -221
  8. package/es/geo/simple.js +22 -34
  9. package/es/geo/transform.js +839 -905
  10. package/es/handler/blockable_map_event.js +46 -66
  11. package/es/handler/box_zoom.js +125 -143
  12. package/es/handler/click_zoom.js +37 -51
  13. package/es/handler/events/event.js +11 -9
  14. package/es/handler/events/map_mouse_event.js +39 -54
  15. package/es/handler/events/map_touch_event.js +54 -73
  16. package/es/handler/events/map_wheel_event.js +22 -38
  17. package/es/handler/events/render_event.js +6 -23
  18. package/es/handler/handler_inertia.js +98 -113
  19. package/es/handler/handler_manager.js +349 -437
  20. package/es/handler/handler_util.js +2 -2
  21. package/es/handler/keyboard.js +98 -110
  22. package/es/handler/map_event.js +81 -117
  23. package/es/handler/mouse/mouse_handler.js +81 -100
  24. package/es/handler/mouse/mousepan_handler.js +16 -39
  25. package/es/handler/mouse/mousepitch_hander.js +18 -40
  26. package/es/handler/mouse/mouserotate_hander.js +18 -40
  27. package/es/handler/mouse/util.js +7 -5
  28. package/es/handler/scroll_zoom.js +221 -231
  29. package/es/handler/shim/dblclick_zoom.js +36 -47
  30. package/es/handler/shim/drag_pan.js +41 -50
  31. package/es/handler/shim/drag_rotate.js +38 -48
  32. package/es/handler/shim/touch_zoom_rotate.js +68 -79
  33. package/es/handler/tap/single_tap_recognizer.js +60 -80
  34. package/es/handler/tap/tap_drag_zoom.js +72 -89
  35. package/es/handler/tap/tap_recognizer.js +37 -45
  36. package/es/handler/tap/tap_zoom.js +67 -95
  37. package/es/handler/touch/touch_pan.js +77 -96
  38. package/es/handler/touch/touch_pitch.js +61 -79
  39. package/es/handler/touch/touch_rotate.js +47 -67
  40. package/es/handler/touch/touch_zoom.js +29 -46
  41. package/es/handler/touch/two_touch.js +79 -104
  42. package/es/hash.js +75 -88
  43. package/es/map.js +318 -284
  44. package/es/util.js +18 -37
  45. package/es/utils/Aabb.js +60 -100
  46. package/es/utils/dom.js +32 -55
  47. package/es/utils/performance.js +25 -29
  48. package/es/utils/primitives.js +33 -42
  49. package/es/utils/task_queue.js +47 -76
  50. package/lib/camera.d.ts +86 -0
  51. package/lib/camera.js +597 -672
  52. package/lib/earthmap.d.ts +69 -0
  53. package/lib/earthmap.js +314 -276
  54. package/lib/geo/edge_insets.d.ts +54 -0
  55. package/lib/geo/edge_insets.js +58 -70
  56. package/lib/geo/lng_lat.d.ts +18 -0
  57. package/lib/geo/lng_lat.js +50 -62
  58. package/lib/geo/lng_lat_bounds.d.ts +25 -0
  59. package/lib/geo/lng_lat_bounds.js +102 -136
  60. package/lib/geo/mercator.d.ts +30 -0
  61. package/lib/geo/mercator.js +26 -37
  62. package/lib/geo/point.d.ts +40 -0
  63. package/lib/geo/point.js +151 -220
  64. package/lib/geo/simple.d.ts +30 -0
  65. package/lib/geo/simple.js +25 -36
  66. package/lib/geo/transform.d.ts +198 -0
  67. package/lib/geo/transform.js +844 -907
  68. package/lib/handler/IHandler.d.ts +34 -0
  69. package/lib/handler/blockable_map_event.d.ts +17 -0
  70. package/lib/handler/blockable_map_event.js +48 -65
  71. package/lib/handler/box_zoom.d.ts +59 -0
  72. package/lib/handler/box_zoom.js +126 -143
  73. package/lib/handler/click_zoom.d.ts +16 -0
  74. package/lib/handler/click_zoom.js +38 -50
  75. package/lib/handler/events/event.d.ts +4 -0
  76. package/lib/handler/events/event.js +12 -9
  77. package/lib/handler/events/index.d.ts +4 -0
  78. package/lib/handler/events/index.js +3 -3
  79. package/lib/handler/events/map_mouse_event.d.ts +34 -0
  80. package/lib/handler/events/map_mouse_event.js +41 -52
  81. package/lib/handler/events/map_touch_event.d.ts +57 -0
  82. package/lib/handler/events/map_touch_event.js +56 -71
  83. package/lib/handler/events/map_wheel_event.d.ts +33 -0
  84. package/lib/handler/events/map_wheel_event.js +23 -37
  85. package/lib/handler/events/render_event.d.ts +5 -0
  86. package/lib/handler/events/render_event.js +7 -22
  87. package/lib/handler/handler_inertia.d.ts +23 -0
  88. package/lib/handler/handler_inertia.js +102 -112
  89. package/lib/handler/handler_manager.d.ts +61 -0
  90. package/lib/handler/handler_manager.js +351 -437
  91. package/lib/handler/handler_util.d.ts +4 -0
  92. package/lib/handler/handler_util.js +2 -2
  93. package/lib/handler/keyboard.d.ts +36 -0
  94. package/lib/handler/keyboard.js +98 -110
  95. package/lib/handler/map_event.d.ts +29 -0
  96. package/lib/handler/map_event.js +83 -116
  97. package/lib/handler/mouse/index.d.ts +4 -0
  98. package/lib/handler/mouse/index.js +3 -3
  99. package/lib/handler/mouse/mouse_handler.d.ts +22 -0
  100. package/lib/handler/mouse/mouse_handler.js +83 -99
  101. package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
  102. package/lib/handler/mouse/mousepan_handler.js +19 -38
  103. package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
  104. package/lib/handler/mouse/mousepitch_hander.js +21 -39
  105. package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
  106. package/lib/handler/mouse/mouserotate_hander.js +21 -39
  107. package/lib/handler/mouse/util.d.ts +6 -0
  108. package/lib/handler/mouse/util.js +7 -6
  109. package/lib/handler/scroll_zoom.d.ts +93 -0
  110. package/lib/handler/scroll_zoom.js +221 -231
  111. package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
  112. package/lib/handler/shim/dblclick_zoom.js +37 -46
  113. package/lib/handler/shim/drag_pan.d.ts +61 -0
  114. package/lib/handler/shim/drag_pan.js +42 -49
  115. package/lib/handler/shim/drag_rotate.d.ts +46 -0
  116. package/lib/handler/shim/drag_rotate.js +39 -47
  117. package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
  118. package/lib/handler/shim/touch_zoom_rotate.js +69 -78
  119. package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
  120. package/lib/handler/tap/single_tap_recognizer.js +63 -79
  121. package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
  122. package/lib/handler/tap/tap_drag_zoom.js +74 -88
  123. package/lib/handler/tap/tap_recognizer.d.ts +17 -0
  124. package/lib/handler/tap/tap_recognizer.js +41 -47
  125. package/lib/handler/tap/tap_zoom.d.ts +22 -0
  126. package/lib/handler/tap/tap_zoom.js +69 -94
  127. package/lib/handler/touch/index.d.ts +5 -0
  128. package/lib/handler/touch/index.js +4 -4
  129. package/lib/handler/touch/touch_pan.d.ts +30 -0
  130. package/lib/handler/touch/touch_pan.js +79 -95
  131. package/lib/handler/touch/touch_pitch.d.ts +13 -0
  132. package/lib/handler/touch/touch_pitch.js +64 -78
  133. package/lib/handler/touch/touch_rotate.d.ts +12 -0
  134. package/lib/handler/touch/touch_rotate.js +50 -66
  135. package/lib/handler/touch/touch_zoom.d.ts +12 -0
  136. package/lib/handler/touch/touch_zoom.js +32 -45
  137. package/lib/handler/touch/two_touch.d.ts +23 -0
  138. package/lib/handler/touch/two_touch.js +81 -103
  139. package/lib/hash.d.ts +14 -0
  140. package/lib/hash.js +75 -88
  141. package/lib/index.d.ts +4 -0
  142. package/lib/index.js +4 -4
  143. package/lib/interface.d.ts +34 -0
  144. package/lib/map.d.ts +70 -0
  145. package/lib/map.js +319 -284
  146. package/lib/util.d.ts +25 -0
  147. package/lib/util.js +20 -36
  148. package/lib/utils/Aabb.d.ts +12 -0
  149. package/lib/utils/Aabb.js +61 -99
  150. package/lib/utils/dom.d.ts +4 -0
  151. package/lib/utils/dom.js +34 -55
  152. package/lib/utils/performance.d.ts +17 -0
  153. package/lib/utils/performance.js +25 -29
  154. package/lib/utils/primitives.d.ts +6 -0
  155. package/lib/utils/primitives.js +34 -41
  156. package/lib/utils/task_queue.d.ts +13 -0
  157. package/lib/utils/task_queue.js +47 -76
  158. package/package.json +25 -32
@@ -1,93 +1,75 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _get from "@babel/runtime/helpers/esm/get";
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
- 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
- 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";
9
2
  // @ts-ignore
10
3
 
11
4
  import TwoTouchHandler from "./two_touch";
12
5
  function isVertical(vector) {
13
6
  return Math.abs(vector.y) > Math.abs(vector.x);
14
7
  }
15
- var ALLOWED_SINGLE_TOUCH_TIME = 100;
16
- var TouchPitchHandler = /*#__PURE__*/function (_TwoTouchHandler) {
17
- _inherits(TouchPitchHandler, _TwoTouchHandler);
18
- var _super = _createSuper(TouchPitchHandler);
19
- function TouchPitchHandler() {
20
- _classCallCheck(this, TouchPitchHandler);
21
- return _super.apply(this, arguments);
8
+ const ALLOWED_SINGLE_TOUCH_TIME = 100;
9
+ export default class TouchPitchHandler extends TwoTouchHandler {
10
+ constructor(...args) {
11
+ super(...args);
12
+ _defineProperty(this, "valid", void 0);
13
+ _defineProperty(this, "firstMove", void 0);
14
+ _defineProperty(this, "lastPoints", void 0);
22
15
  }
23
- _createClass(TouchPitchHandler, [{
24
- key: "reset",
25
- value: function reset() {
26
- _get(_getPrototypeOf(TouchPitchHandler.prototype), "reset", this).call(this);
27
- this.valid = undefined;
28
- // @ts-ignore
29
- delete this.firstMove;
30
- // @ts-ignore
31
- delete this.lastPoints;
16
+ reset() {
17
+ super.reset();
18
+ this.valid = undefined;
19
+ // @ts-ignore
20
+ delete this.firstMove;
21
+ // @ts-ignore
22
+ delete this.lastPoints;
23
+ }
24
+ start(points) {
25
+ this.lastPoints = points;
26
+ if (isVertical(points[0].sub(points[1]))) {
27
+ // fingers are more horizontal than vertical
28
+ this.valid = false;
32
29
  }
33
- }, {
34
- key: "start",
35
- value: function start(points) {
36
- this.lastPoints = points;
37
- if (isVertical(points[0].sub(points[1]))) {
38
- // fingers are more horizontal than vertical
39
- this.valid = false;
40
- }
30
+ }
31
+ move(points, center, e) {
32
+ const vectorA = points[0].sub(this.lastPoints[0]);
33
+ const vectorB = points[1].sub(this.lastPoints[1]);
34
+ this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
35
+ if (!this.valid) {
36
+ return;
41
37
  }
42
- }, {
43
- key: "move",
44
- value: function move(points, center, e) {
45
- var vectorA = points[0].sub(this.lastPoints[0]);
46
- var vectorB = points[1].sub(this.lastPoints[1]);
47
- this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
48
- if (!this.valid) {
49
- return;
50
- }
51
- this.lastPoints = points;
52
- this.active = true;
53
- var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
54
- var degreesPerPixelMoved = -0.5;
55
- return {
56
- pitchDelta: yDeltaAverage * degreesPerPixelMoved
57
- };
38
+ this.lastPoints = points;
39
+ this.active = true;
40
+ const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
41
+ const degreesPerPixelMoved = -0.5;
42
+ return {
43
+ pitchDelta: yDeltaAverage * degreesPerPixelMoved
44
+ };
45
+ }
46
+ gestureBeginsVertically(vectorA, vectorB, timeStamp) {
47
+ if (this.valid !== undefined) {
48
+ return this.valid;
58
49
  }
59
- }, {
60
- key: "gestureBeginsVertically",
61
- value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
62
- if (this.valid !== undefined) {
63
- return this.valid;
64
- }
65
- var threshold = 2;
66
- var movedA = vectorA.mag() >= threshold;
67
- var movedB = vectorB.mag() >= threshold;
50
+ const threshold = 2;
51
+ const movedA = vectorA.mag() >= threshold;
52
+ const movedB = vectorB.mag() >= threshold;
68
53
 
69
- // neither finger has moved a meaningful amount, wait
70
- if (!movedA && !movedB) {
71
- return;
72
- }
54
+ // neither finger has moved a meaningful amount, wait
55
+ if (!movedA && !movedB) {
56
+ return;
57
+ }
73
58
 
74
- // One finger has moved and the other has not.
75
- // If enough time has passed, decide it is not a pitch.
76
- if (!movedA || !movedB) {
77
- if (this.firstMove === undefined) {
78
- this.firstMove = timeStamp;
79
- }
80
- if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
81
- // still waiting for a movement from the second finger
82
- return undefined;
83
- } else {
84
- return false;
85
- }
59
+ // One finger has moved and the other has not.
60
+ // If enough time has passed, decide it is not a pitch.
61
+ if (!movedA || !movedB) {
62
+ if (this.firstMove === undefined) {
63
+ this.firstMove = timeStamp;
64
+ }
65
+ if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
66
+ // still waiting for a movement from the second finger
67
+ return undefined;
68
+ } else {
69
+ return false;
86
70
  }
87
- var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
88
- return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
89
71
  }
90
- }]);
91
- return TouchPitchHandler;
92
- }(TwoTouchHandler);
93
- export { TouchPitchHandler as default };
72
+ const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
73
+ return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
74
+ }
75
+ }
@@ -1,77 +1,57 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _get from "@babel/runtime/helpers/esm/get";
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
- 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
- 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";
9
2
  // @ts-ignore
10
3
 
11
4
  import TwoTouchHandler from "./two_touch";
12
- var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
5
+ const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
13
6
 
14
7
  function getBearingDelta(a, b) {
15
8
  return a.angleWith(b) * 180 / Math.PI;
16
9
  }
17
- var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
18
- _inherits(TouchRotateHandler, _TwoTouchHandler);
19
- var _super = _createSuper(TouchRotateHandler);
20
- function TouchRotateHandler() {
21
- _classCallCheck(this, TouchRotateHandler);
22
- return _super.apply(this, arguments);
10
+ export default class TouchRotateHandler extends TwoTouchHandler {
11
+ constructor(...args) {
12
+ super(...args);
13
+ _defineProperty(this, "minDiameter", void 0);
23
14
  }
24
- _createClass(TouchRotateHandler, [{
25
- key: "reset",
26
- value: function reset() {
27
- _get(_getPrototypeOf(TouchRotateHandler.prototype), "reset", this).call(this);
28
- // @ts-ignore
29
- delete this.minDiameter;
30
- // @ts-ignore
31
- delete this.startVector;
32
- // @ts-ignore
33
- delete this.vector;
34
- }
35
- }, {
36
- key: "start",
37
- value: function start(points) {
38
- this.startVector = this.vector = points[0].sub(points[1]);
39
- this.minDiameter = points[0].dist(points[1]);
40
- }
41
- }, {
42
- key: "move",
43
- value: function move(points, pinchAround) {
44
- var lastVector = this.vector;
45
- this.vector = points[0].sub(points[1]);
46
- if (!this.active && this.isBelowThreshold(this.vector)) {
47
- return;
48
- }
49
- this.active = true;
50
- return {
51
- bearingDelta: getBearingDelta(this.vector, lastVector),
52
- pinchAround: pinchAround
53
- };
15
+ reset() {
16
+ super.reset();
17
+ // @ts-ignore
18
+ delete this.minDiameter;
19
+ // @ts-ignore
20
+ delete this.startVector;
21
+ // @ts-ignore
22
+ delete this.vector;
23
+ }
24
+ start(points) {
25
+ this.startVector = this.vector = points[0].sub(points[1]);
26
+ this.minDiameter = points[0].dist(points[1]);
27
+ }
28
+ move(points, pinchAround) {
29
+ const lastVector = this.vector;
30
+ this.vector = points[0].sub(points[1]);
31
+ if (!this.active && this.isBelowThreshold(this.vector)) {
32
+ return;
54
33
  }
55
- }, {
56
- key: "isBelowThreshold",
57
- value: function isBelowThreshold(vector) {
58
- /*
59
- * The threshold before a rotation actually happens is configured in
60
- * pixels alongth circumference of the circle formed by the two fingers.
61
- * This makes the threshold in degrees larger when the fingers are close
62
- * together and smaller when the fingers are far apart.
63
- *
64
- * Use the smallest diameter from the whole gesture to reduce sensitivity
65
- * when pinching in and out.
66
- */
34
+ this.active = true;
35
+ return {
36
+ bearingDelta: getBearingDelta(this.vector, lastVector),
37
+ pinchAround
38
+ };
39
+ }
40
+ isBelowThreshold(vector) {
41
+ /*
42
+ * The threshold before a rotation actually happens is configured in
43
+ * pixels alongth circumference of the circle formed by the two fingers.
44
+ * This makes the threshold in degrees larger when the fingers are close
45
+ * together and smaller when the fingers are far apart.
46
+ *
47
+ * Use the smallest diameter from the whole gesture to reduce sensitivity
48
+ * when pinching in and out.
49
+ */
67
50
 
68
- this.minDiameter = Math.min(this.minDiameter, vector.mag());
69
- var circumference = Math.PI * this.minDiameter;
70
- var threshold = ROTATION_THRESHOLD / circumference * 360;
71
- var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
72
- return Math.abs(bearingDeltaSinceStart) < threshold;
73
- }
74
- }]);
75
- return TouchRotateHandler;
76
- }(TwoTouchHandler);
77
- export { TouchRotateHandler as default };
51
+ this.minDiameter = Math.min(this.minDiameter, vector.mag());
52
+ const circumference = Math.PI * this.minDiameter;
53
+ const threshold = ROTATION_THRESHOLD / circumference * 360;
54
+ const bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
55
+ return Math.abs(bearingDeltaSinceStart) < threshold;
56
+ }
57
+ }
@@ -1,54 +1,37 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _get from "@babel/runtime/helpers/esm/get";
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
- 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
- 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";
9
2
  // @ts-ignore
10
3
 
11
4
  import TwoTouchHandler from "./two_touch";
12
- var ZOOM_THRESHOLD = 0.1;
5
+ const ZOOM_THRESHOLD = 0.1;
13
6
  function getZoomDelta(distance, lastDistance) {
14
7
  return Math.log(distance / lastDistance) / Math.LN2;
15
8
  }
16
- var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
17
- _inherits(TouchZoomHandler, _TwoTouchHandler);
18
- var _super = _createSuper(TouchZoomHandler);
19
- function TouchZoomHandler() {
20
- _classCallCheck(this, TouchZoomHandler);
21
- return _super.apply(this, arguments);
9
+ export default class TouchZoomHandler extends TwoTouchHandler {
10
+ constructor(...args) {
11
+ super(...args);
12
+ _defineProperty(this, "distance", void 0);
13
+ _defineProperty(this, "startDistance", void 0);
22
14
  }
23
- _createClass(TouchZoomHandler, [{
24
- key: "reset",
25
- value: function reset() {
26
- _get(_getPrototypeOf(TouchZoomHandler.prototype), "reset", this).call(this);
27
- // @ts-ignore
28
- delete this.distance;
29
- // @ts-ignore
30
- delete this.startDistance;
31
- }
32
- }, {
33
- key: "start",
34
- value: function start(points) {
35
- this.startDistance = this.distance = points[0].dist(points[1]);
36
- }
37
- }, {
38
- key: "move",
39
- value: function move(points, pinchAround) {
40
- var lastDistance = this.distance;
41
- this.distance = points[0].dist(points[1]);
42
- if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
43
- return;
44
- }
45
- this.active = true;
46
- return {
47
- zoomDelta: getZoomDelta(this.distance, lastDistance),
48
- pinchAround: pinchAround
49
- };
15
+ reset() {
16
+ super.reset();
17
+ // @ts-ignore
18
+ delete this.distance;
19
+ // @ts-ignore
20
+ delete this.startDistance;
21
+ }
22
+ start(points) {
23
+ this.startDistance = this.distance = points[0].dist(points[1]);
24
+ }
25
+ move(points, pinchAround) {
26
+ const lastDistance = this.distance;
27
+ this.distance = points[0].dist(points[1]);
28
+ if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
29
+ return;
50
30
  }
51
- }]);
52
- return TouchZoomHandler;
53
- }(TwoTouchHandler);
54
- export { TouchZoomHandler as default };
31
+ this.active = true;
32
+ return {
33
+ zoomDelta: getZoomDelta(this.distance, lastDistance),
34
+ pinchAround
35
+ };
36
+ }
37
+ }
@@ -1,121 +1,96 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
2
  // @ts-ignore
5
3
 
6
4
  import DOM from "../../utils/dom";
7
- var TwoTouchHandler = /*#__PURE__*/function () {
8
- function TwoTouchHandler() {
9
- _classCallCheck(this, TwoTouchHandler);
5
+ export default class TwoTouchHandler {
6
+ constructor() {
7
+ _defineProperty(this, "enabled", void 0);
8
+ _defineProperty(this, "active", void 0);
9
+ _defineProperty(this, "firstTwoTouches", void 0);
10
+ _defineProperty(this, "vector", void 0);
11
+ _defineProperty(this, "startVector", void 0);
12
+ _defineProperty(this, "aroundCenter", void 0);
10
13
  this.reset();
11
14
  }
12
- _createClass(TwoTouchHandler, [{
13
- key: "reset",
14
- value: function reset() {
15
- this.active = false;
16
- // @ts-ignore
17
- delete this.firstTwoTouches;
18
- }
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- }, {
21
- key: "start",
22
- value: function start(points) {
23
- return;
24
- } // eslint-disable-line
25
- }, {
26
- key: "move",
27
- value: function move(
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- points,
30
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- pinchAround,
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- e) {
34
- return;
35
- } // eslint-disable-line
36
- }, {
37
- key: "touchstart",
38
- value: function touchstart(e, points, mapTouches) {
39
- if (this.firstTwoTouches || mapTouches.length < 2) {
40
- return;
41
- }
42
- this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
15
+ reset() {
16
+ this.active = false;
17
+ // @ts-ignore
18
+ delete this.firstTwoTouches;
19
+ }
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ start(points) {
22
+ return;
23
+ } // eslint-disable-line
24
+ move(
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ points,
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ pinchAround,
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ e) {
31
+ return;
32
+ } // eslint-disable-line
43
33
 
44
- // implemented by child classes
45
- this.start([points[0], points[1]]);
34
+ touchstart(e, points, mapTouches) {
35
+ if (this.firstTwoTouches || mapTouches.length < 2) {
36
+ return;
46
37
  }
47
- }, {
48
- key: "touchmove",
49
- value: function touchmove(e, points, mapTouches) {
50
- if (!this.firstTwoTouches) {
51
- return;
52
- }
53
- e.preventDefault();
54
- var _this$firstTwoTouches = _slicedToArray(this.firstTwoTouches, 2),
55
- idA = _this$firstTwoTouches[0],
56
- idB = _this$firstTwoTouches[1];
57
- var a = getTouchById(mapTouches, points, idA);
58
- var b = getTouchById(mapTouches, points, idB);
59
- if (!a || !b) {
60
- return;
61
- }
62
- var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
38
+ this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
63
39
 
64
- // implemented by child classes
65
- return this.move([a, b], pinchAround, e);
66
- }
67
- }, {
68
- key: "touchend",
69
- value: function touchend(e, points, mapTouches) {
70
- if (!this.firstTwoTouches) {
71
- return;
72
- }
73
- var _this$firstTwoTouches2 = _slicedToArray(this.firstTwoTouches, 2),
74
- idA = _this$firstTwoTouches2[0],
75
- idB = _this$firstTwoTouches2[1];
76
- var a = getTouchById(mapTouches, points, idA);
77
- var b = getTouchById(mapTouches, points, idB);
78
- if (a && b) {
79
- return;
80
- }
81
- if (this.active) {
82
- DOM.suppressClick();
83
- }
84
- this.reset();
85
- }
86
- }, {
87
- key: "touchcancel",
88
- value: function touchcancel() {
89
- this.reset();
40
+ // implemented by child classes
41
+ this.start([points[0], points[1]]);
42
+ }
43
+ touchmove(e, points, mapTouches) {
44
+ if (!this.firstTwoTouches) {
45
+ return;
90
46
  }
91
- }, {
92
- key: "enable",
93
- value: function enable(options) {
94
- this.enabled = true;
95
- this.aroundCenter = !!options && options.around === 'center';
47
+ e.preventDefault();
48
+ const [idA, idB] = this.firstTwoTouches;
49
+ const a = getTouchById(mapTouches, points, idA);
50
+ const b = getTouchById(mapTouches, points, idB);
51
+ if (!a || !b) {
52
+ return;
96
53
  }
97
- }, {
98
- key: "disable",
99
- value: function disable() {
100
- this.enabled = false;
101
- this.reset();
54
+ const pinchAround = this.aroundCenter ? null : a.add(b).div(2);
55
+
56
+ // implemented by child classes
57
+ return this.move([a, b], pinchAround, e);
58
+ }
59
+ touchend(e, points, mapTouches) {
60
+ if (!this.firstTwoTouches) {
61
+ return;
102
62
  }
103
- }, {
104
- key: "isEnabled",
105
- value: function isEnabled() {
106
- return this.enabled;
63
+ const [idA, idB] = this.firstTwoTouches;
64
+ const a = getTouchById(mapTouches, points, idA);
65
+ const b = getTouchById(mapTouches, points, idB);
66
+ if (a && b) {
67
+ return;
107
68
  }
108
- }, {
109
- key: "isActive",
110
- value: function isActive() {
111
- return this.active;
69
+ if (this.active) {
70
+ DOM.suppressClick();
112
71
  }
113
- }]);
114
- return TwoTouchHandler;
115
- }();
116
- export { TwoTouchHandler as default };
72
+ this.reset();
73
+ }
74
+ touchcancel() {
75
+ this.reset();
76
+ }
77
+ enable(options) {
78
+ this.enabled = true;
79
+ this.aroundCenter = !!options && options.around === 'center';
80
+ }
81
+ disable() {
82
+ this.enabled = false;
83
+ this.reset();
84
+ }
85
+ isEnabled() {
86
+ return this.enabled;
87
+ }
88
+ isActive() {
89
+ return this.active;
90
+ }
91
+ }
117
92
  function getTouchById(mapTouches, points, identifier) {
118
- for (var i = 0; i < mapTouches.length; i++) {
93
+ for (let i = 0; i < mapTouches.length; i++) {
119
94
  if (mapTouches[i].identifier === identifier) {
120
95
  return points[i];
121
96
  }