@antv/l7-map 2.21.0 → 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 -6
  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 -43
  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 -7
  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 -42
  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
@@ -5,93 +5,79 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
9
  var _two_touch = _interopRequireDefault(require("./two_touch"));
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
- 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; } } // @ts-ignore
10
+ // @ts-ignore
11
+
17
12
  function isVertical(vector) {
18
13
  return Math.abs(vector.y) > Math.abs(vector.x);
19
14
  }
20
- var ALLOWED_SINGLE_TOUCH_TIME = 100;
21
- var TouchPitchHandler = exports.default = /*#__PURE__*/function (_TwoTouchHandler) {
22
- (0, _inherits2.default)(TouchPitchHandler, _TwoTouchHandler);
23
- var _super = _createSuper(TouchPitchHandler);
24
- function TouchPitchHandler() {
25
- (0, _classCallCheck2.default)(this, TouchPitchHandler);
26
- return _super.apply(this, arguments);
15
+ const ALLOWED_SINGLE_TOUCH_TIME = 100;
16
+ class TouchPitchHandler extends _two_touch.default {
17
+ constructor(...args) {
18
+ super(...args);
19
+ (0, _defineProperty2.default)(this, "valid", void 0);
20
+ (0, _defineProperty2.default)(this, "firstMove", void 0);
21
+ (0, _defineProperty2.default)(this, "lastPoints", void 0);
22
+ }
23
+ reset() {
24
+ super.reset();
25
+ this.valid = undefined;
26
+ // @ts-ignore
27
+ delete this.firstMove;
28
+ // @ts-ignore
29
+ delete this.lastPoints;
27
30
  }
28
- (0, _createClass2.default)(TouchPitchHandler, [{
29
- key: "reset",
30
- value: function reset() {
31
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchPitchHandler.prototype), "reset", this).call(this);
32
- this.valid = undefined;
33
- // @ts-ignore
34
- delete this.firstMove;
35
- // @ts-ignore
36
- delete this.lastPoints;
31
+ start(points) {
32
+ this.lastPoints = points;
33
+ if (isVertical(points[0].sub(points[1]))) {
34
+ // fingers are more horizontal than vertical
35
+ this.valid = false;
37
36
  }
38
- }, {
39
- key: "start",
40
- value: function start(points) {
41
- this.lastPoints = points;
42
- if (isVertical(points[0].sub(points[1]))) {
43
- // fingers are more horizontal than vertical
44
- this.valid = false;
45
- }
37
+ }
38
+ move(points, center, e) {
39
+ const vectorA = points[0].sub(this.lastPoints[0]);
40
+ const vectorB = points[1].sub(this.lastPoints[1]);
41
+ this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
42
+ if (!this.valid) {
43
+ return;
46
44
  }
47
- }, {
48
- key: "move",
49
- value: function move(points, center, e) {
50
- var vectorA = points[0].sub(this.lastPoints[0]);
51
- var vectorB = points[1].sub(this.lastPoints[1]);
52
- this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
53
- if (!this.valid) {
54
- return;
55
- }
56
- this.lastPoints = points;
57
- this.active = true;
58
- var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
59
- var degreesPerPixelMoved = -0.5;
60
- return {
61
- pitchDelta: yDeltaAverage * degreesPerPixelMoved
62
- };
45
+ this.lastPoints = points;
46
+ this.active = true;
47
+ const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
48
+ const degreesPerPixelMoved = -0.5;
49
+ return {
50
+ pitchDelta: yDeltaAverage * degreesPerPixelMoved
51
+ };
52
+ }
53
+ gestureBeginsVertically(vectorA, vectorB, timeStamp) {
54
+ if (this.valid !== undefined) {
55
+ return this.valid;
63
56
  }
64
- }, {
65
- key: "gestureBeginsVertically",
66
- value: function gestureBeginsVertically(vectorA, vectorB, timeStamp) {
67
- if (this.valid !== undefined) {
68
- return this.valid;
69
- }
70
- var threshold = 2;
71
- var movedA = vectorA.mag() >= threshold;
72
- var movedB = vectorB.mag() >= threshold;
57
+ const threshold = 2;
58
+ const movedA = vectorA.mag() >= threshold;
59
+ const movedB = vectorB.mag() >= threshold;
73
60
 
74
- // neither finger has moved a meaningful amount, wait
75
- if (!movedA && !movedB) {
76
- return;
77
- }
61
+ // neither finger has moved a meaningful amount, wait
62
+ if (!movedA && !movedB) {
63
+ return;
64
+ }
78
65
 
79
- // One finger has moved and the other has not.
80
- // If enough time has passed, decide it is not a pitch.
81
- if (!movedA || !movedB) {
82
- if (this.firstMove === undefined) {
83
- this.firstMove = timeStamp;
84
- }
85
- if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
86
- // still waiting for a movement from the second finger
87
- return undefined;
88
- } else {
89
- return false;
90
- }
66
+ // One finger has moved and the other has not.
67
+ // If enough time has passed, decide it is not a pitch.
68
+ if (!movedA || !movedB) {
69
+ if (this.firstMove === undefined) {
70
+ this.firstMove = timeStamp;
71
+ }
72
+ if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
73
+ // still waiting for a movement from the second finger
74
+ return undefined;
75
+ } else {
76
+ return false;
91
77
  }
92
- var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
93
- return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
94
78
  }
95
- }]);
96
- return TouchPitchHandler;
97
- }(_two_touch.default);
79
+ const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
80
+ return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
81
+ }
82
+ }
83
+ exports.default = TouchPitchHandler;
@@ -0,0 +1,12 @@
1
+ import type 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
+ }
@@ -5,77 +5,61 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
9
  var _two_touch = _interopRequireDefault(require("./two_touch"));
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
- 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; } } // @ts-ignore
17
- var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
10
+ // @ts-ignore
11
+
12
+ const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
18
13
 
19
14
  function getBearingDelta(a, b) {
20
15
  return a.angleWith(b) * 180 / Math.PI;
21
16
  }
22
- var TouchRotateHandler = exports.default = /*#__PURE__*/function (_TwoTouchHandler) {
23
- (0, _inherits2.default)(TouchRotateHandler, _TwoTouchHandler);
24
- var _super = _createSuper(TouchRotateHandler);
25
- function TouchRotateHandler() {
26
- (0, _classCallCheck2.default)(this, TouchRotateHandler);
27
- return _super.apply(this, arguments);
17
+ class TouchRotateHandler extends _two_touch.default {
18
+ constructor(...args) {
19
+ super(...args);
20
+ (0, _defineProperty2.default)(this, "minDiameter", void 0);
28
21
  }
29
- (0, _createClass2.default)(TouchRotateHandler, [{
30
- key: "reset",
31
- value: function reset() {
32
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchRotateHandler.prototype), "reset", this).call(this);
33
- // @ts-ignore
34
- delete this.minDiameter;
35
- // @ts-ignore
36
- delete this.startVector;
37
- // @ts-ignore
38
- delete this.vector;
39
- }
40
- }, {
41
- key: "start",
42
- value: function start(points) {
43
- this.startVector = this.vector = points[0].sub(points[1]);
44
- this.minDiameter = points[0].dist(points[1]);
45
- }
46
- }, {
47
- key: "move",
48
- value: function move(points, pinchAround) {
49
- var lastVector = this.vector;
50
- this.vector = points[0].sub(points[1]);
51
- if (!this.active && this.isBelowThreshold(this.vector)) {
52
- return;
53
- }
54
- this.active = true;
55
- return {
56
- bearingDelta: getBearingDelta(this.vector, lastVector),
57
- pinchAround: pinchAround
58
- };
22
+ reset() {
23
+ super.reset();
24
+ // @ts-ignore
25
+ delete this.minDiameter;
26
+ // @ts-ignore
27
+ delete this.startVector;
28
+ // @ts-ignore
29
+ delete this.vector;
30
+ }
31
+ start(points) {
32
+ this.startVector = this.vector = points[0].sub(points[1]);
33
+ this.minDiameter = points[0].dist(points[1]);
34
+ }
35
+ move(points, pinchAround) {
36
+ const lastVector = this.vector;
37
+ this.vector = points[0].sub(points[1]);
38
+ if (!this.active && this.isBelowThreshold(this.vector)) {
39
+ return;
59
40
  }
60
- }, {
61
- key: "isBelowThreshold",
62
- value: function isBelowThreshold(vector) {
63
- /*
64
- * The threshold before a rotation actually happens is configured in
65
- * pixels alongth circumference of the circle formed by the two fingers.
66
- * This makes the threshold in degrees larger when the fingers are close
67
- * together and smaller when the fingers are far apart.
68
- *
69
- * Use the smallest diameter from the whole gesture to reduce sensitivity
70
- * when pinching in and out.
71
- */
41
+ this.active = true;
42
+ return {
43
+ bearingDelta: getBearingDelta(this.vector, lastVector),
44
+ pinchAround
45
+ };
46
+ }
47
+ isBelowThreshold(vector) {
48
+ /*
49
+ * The threshold before a rotation actually happens is configured in
50
+ * pixels alongth circumference of the circle formed by the two fingers.
51
+ * This makes the threshold in degrees larger when the fingers are close
52
+ * together and smaller when the fingers are far apart.
53
+ *
54
+ * Use the smallest diameter from the whole gesture to reduce sensitivity
55
+ * when pinching in and out.
56
+ */
72
57
 
73
- this.minDiameter = Math.min(this.minDiameter, vector.mag());
74
- var circumference = Math.PI * this.minDiameter;
75
- var threshold = ROTATION_THRESHOLD / circumference * 360;
76
- var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
77
- return Math.abs(bearingDeltaSinceStart) < threshold;
78
- }
79
- }]);
80
- return TouchRotateHandler;
81
- }(_two_touch.default);
58
+ this.minDiameter = Math.min(this.minDiameter, vector.mag());
59
+ const circumference = Math.PI * this.minDiameter;
60
+ const threshold = ROTATION_THRESHOLD / circumference * 360;
61
+ const bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
62
+ return Math.abs(bearingDeltaSinceStart) < threshold;
63
+ }
64
+ }
65
+ exports.default = TouchRotateHandler;
@@ -0,0 +1,12 @@
1
+ import type 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
+ }
@@ -5,54 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
9
  var _two_touch = _interopRequireDefault(require("./two_touch"));
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
16
- 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; } } // @ts-ignore
17
- var ZOOM_THRESHOLD = 0.1;
10
+ // @ts-ignore
11
+
12
+ const ZOOM_THRESHOLD = 0.1;
18
13
  function getZoomDelta(distance, lastDistance) {
19
14
  return Math.log(distance / lastDistance) / Math.LN2;
20
15
  }
21
- var TouchZoomHandler = exports.default = /*#__PURE__*/function (_TwoTouchHandler) {
22
- (0, _inherits2.default)(TouchZoomHandler, _TwoTouchHandler);
23
- var _super = _createSuper(TouchZoomHandler);
24
- function TouchZoomHandler() {
25
- (0, _classCallCheck2.default)(this, TouchZoomHandler);
26
- return _super.apply(this, arguments);
16
+ class TouchZoomHandler extends _two_touch.default {
17
+ constructor(...args) {
18
+ super(...args);
19
+ (0, _defineProperty2.default)(this, "distance", void 0);
20
+ (0, _defineProperty2.default)(this, "startDistance", void 0);
27
21
  }
28
- (0, _createClass2.default)(TouchZoomHandler, [{
29
- key: "reset",
30
- value: function reset() {
31
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchZoomHandler.prototype), "reset", this).call(this);
32
- // @ts-ignore
33
- delete this.distance;
34
- // @ts-ignore
35
- delete this.startDistance;
36
- }
37
- }, {
38
- key: "start",
39
- value: function start(points) {
40
- this.startDistance = this.distance = points[0].dist(points[1]);
41
- }
42
- }, {
43
- key: "move",
44
- value: function move(points, pinchAround) {
45
- var lastDistance = this.distance;
46
- this.distance = points[0].dist(points[1]);
47
- if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
48
- return;
49
- }
50
- this.active = true;
51
- return {
52
- zoomDelta: getZoomDelta(this.distance, lastDistance),
53
- pinchAround: pinchAround
54
- };
22
+ reset() {
23
+ super.reset();
24
+ // @ts-ignore
25
+ delete this.distance;
26
+ // @ts-ignore
27
+ delete this.startDistance;
28
+ }
29
+ start(points) {
30
+ this.startDistance = this.distance = points[0].dist(points[1]);
31
+ }
32
+ move(points, pinchAround) {
33
+ const lastDistance = this.distance;
34
+ this.distance = points[0].dist(points[1]);
35
+ if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
36
+ return;
55
37
  }
56
- }]);
57
- return TouchZoomHandler;
58
- }(_two_touch.default);
38
+ this.active = true;
39
+ return {
40
+ zoomDelta: getZoomDelta(this.distance, lastDistance),
41
+ pinchAround
42
+ };
43
+ }
44
+ }
45
+ exports.default = TouchZoomHandler;
@@ -0,0 +1,23 @@
1
+ import type 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
+ }
@@ -5,122 +5,100 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
9
  var _dom = _interopRequireDefault(require("../../utils/dom"));
12
10
  // @ts-ignore
13
- var TwoTouchHandler = exports.default = /*#__PURE__*/function () {
14
- function TwoTouchHandler() {
15
- (0, _classCallCheck2.default)(this, TwoTouchHandler);
11
+
12
+ class TwoTouchHandler {
13
+ constructor() {
14
+ (0, _defineProperty2.default)(this, "enabled", void 0);
15
+ (0, _defineProperty2.default)(this, "active", void 0);
16
+ (0, _defineProperty2.default)(this, "firstTwoTouches", void 0);
17
+ (0, _defineProperty2.default)(this, "vector", void 0);
18
+ (0, _defineProperty2.default)(this, "startVector", void 0);
19
+ (0, _defineProperty2.default)(this, "aroundCenter", void 0);
16
20
  this.reset();
17
21
  }
18
- (0, _createClass2.default)(TwoTouchHandler, [{
19
- key: "reset",
20
- value: function reset() {
21
- this.active = false;
22
- // @ts-ignore
23
- delete this.firstTwoTouches;
24
- }
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- }, {
27
- key: "start",
28
- value: function start(points) {
29
- return;
30
- } // eslint-disable-line
31
- }, {
32
- key: "move",
33
- value: function move(
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- points,
36
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
- pinchAround,
38
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
- e) {
40
- return;
41
- } // eslint-disable-line
42
- }, {
43
- key: "touchstart",
44
- value: function touchstart(e, points, mapTouches) {
45
- if (this.firstTwoTouches || mapTouches.length < 2) {
46
- return;
47
- }
48
- this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
22
+ reset() {
23
+ this.active = false;
24
+ // @ts-ignore
25
+ delete this.firstTwoTouches;
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ start(points) {
29
+ return;
30
+ } // eslint-disable-line
31
+ move(
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ points,
34
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
+ pinchAround,
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
+ e) {
38
+ return;
39
+ } // eslint-disable-line
49
40
 
50
- // implemented by child classes
51
- this.start([points[0], points[1]]);
41
+ touchstart(e, points, mapTouches) {
42
+ if (this.firstTwoTouches || mapTouches.length < 2) {
43
+ return;
52
44
  }
53
- }, {
54
- key: "touchmove",
55
- value: function touchmove(e, points, mapTouches) {
56
- if (!this.firstTwoTouches) {
57
- return;
58
- }
59
- e.preventDefault();
60
- var _this$firstTwoTouches = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
61
- idA = _this$firstTwoTouches[0],
62
- idB = _this$firstTwoTouches[1];
63
- var a = getTouchById(mapTouches, points, idA);
64
- var b = getTouchById(mapTouches, points, idB);
65
- if (!a || !b) {
66
- return;
67
- }
68
- var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
45
+ this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
69
46
 
70
- // implemented by child classes
71
- return this.move([a, b], pinchAround, e);
72
- }
73
- }, {
74
- key: "touchend",
75
- value: function touchend(e, points, mapTouches) {
76
- if (!this.firstTwoTouches) {
77
- return;
78
- }
79
- var _this$firstTwoTouches2 = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
80
- idA = _this$firstTwoTouches2[0],
81
- idB = _this$firstTwoTouches2[1];
82
- var a = getTouchById(mapTouches, points, idA);
83
- var b = getTouchById(mapTouches, points, idB);
84
- if (a && b) {
85
- return;
86
- }
87
- if (this.active) {
88
- _dom.default.suppressClick();
89
- }
90
- this.reset();
91
- }
92
- }, {
93
- key: "touchcancel",
94
- value: function touchcancel() {
95
- this.reset();
47
+ // implemented by child classes
48
+ this.start([points[0], points[1]]);
49
+ }
50
+ touchmove(e, points, mapTouches) {
51
+ if (!this.firstTwoTouches) {
52
+ return;
96
53
  }
97
- }, {
98
- key: "enable",
99
- value: function enable(options) {
100
- this.enabled = true;
101
- this.aroundCenter = !!options && options.around === 'center';
54
+ e.preventDefault();
55
+ const [idA, idB] = this.firstTwoTouches;
56
+ const a = getTouchById(mapTouches, points, idA);
57
+ const b = getTouchById(mapTouches, points, idB);
58
+ if (!a || !b) {
59
+ return;
102
60
  }
103
- }, {
104
- key: "disable",
105
- value: function disable() {
106
- this.enabled = false;
107
- this.reset();
61
+ const pinchAround = this.aroundCenter ? null : a.add(b).div(2);
62
+
63
+ // implemented by child classes
64
+ return this.move([a, b], pinchAround, e);
65
+ }
66
+ touchend(e, points, mapTouches) {
67
+ if (!this.firstTwoTouches) {
68
+ return;
108
69
  }
109
- }, {
110
- key: "isEnabled",
111
- value: function isEnabled() {
112
- return this.enabled;
70
+ const [idA, idB] = this.firstTwoTouches;
71
+ const a = getTouchById(mapTouches, points, idA);
72
+ const b = getTouchById(mapTouches, points, idB);
73
+ if (a && b) {
74
+ return;
113
75
  }
114
- }, {
115
- key: "isActive",
116
- value: function isActive() {
117
- return this.active;
76
+ if (this.active) {
77
+ _dom.default.suppressClick();
118
78
  }
119
- }]);
120
- return TwoTouchHandler;
121
- }();
79
+ this.reset();
80
+ }
81
+ touchcancel() {
82
+ this.reset();
83
+ }
84
+ enable(options) {
85
+ this.enabled = true;
86
+ this.aroundCenter = !!options && options.around === 'center';
87
+ }
88
+ disable() {
89
+ this.enabled = false;
90
+ this.reset();
91
+ }
92
+ isEnabled() {
93
+ return this.enabled;
94
+ }
95
+ isActive() {
96
+ return this.active;
97
+ }
98
+ }
99
+ exports.default = TwoTouchHandler;
122
100
  function getTouchById(mapTouches, points, identifier) {
123
- for (var i = 0; i < mapTouches.length; i++) {
101
+ for (let i = 0; i < mapTouches.length; i++) {
124
102
  if (mapTouches[i].identifier === identifier) {
125
103
  return points[i];
126
104
  }
package/lib/hash.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Map } from './map';
2
+ declare class Hash {
3
+ private map;
4
+ private updateHash;
5
+ private hashName?;
6
+ constructor(hashName?: string);
7
+ addTo(map: Map): this;
8
+ remove(): this;
9
+ onHashChange: () => boolean;
10
+ private getCurrentHash;
11
+ private getHashString;
12
+ private updateHashUnthrottled;
13
+ }
14
+ export default Hash;