@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.
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,8 +1,8 @@
1
1
  // @ts-ignore
2
2
 
3
3
  export function indexTouches(touches, points) {
4
- var obj = {};
5
- for (var i = 0; i < touches.length; i++) {
4
+ const obj = {};
5
+ for (let i = 0; i < touches.length; i++) {
6
6
  obj[touches[i].identifier] = points[i];
7
7
  }
8
8
  return obj;
@@ -1,6 +1,5 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- var defaultOptions = {
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ const defaultOptions = {
4
3
  panStep: 100,
5
4
  bearingStep: 15,
6
5
  pitchStep: 10
@@ -20,123 +19,112 @@ var defaultOptions = {
20
19
  * - `Shift+⇡`: Increase the pitch by 10 degrees.
21
20
  * - `Shift+⇣`: Decrease the pitch by 10 degrees.
22
21
  */
23
- var KeyboardHandler = /*#__PURE__*/function () {
22
+ class KeyboardHandler {
24
23
  /**
25
24
  * @private
26
25
  */
27
- function KeyboardHandler() {
28
- _classCallCheck(this, KeyboardHandler);
29
- var stepOptions = defaultOptions;
26
+ constructor() {
27
+ _defineProperty(this, "enabled", void 0);
28
+ _defineProperty(this, "active", void 0);
29
+ _defineProperty(this, "panStep", void 0);
30
+ _defineProperty(this, "bearingStep", void 0);
31
+ _defineProperty(this, "pitchStep", void 0);
32
+ const stepOptions = defaultOptions;
30
33
  this.panStep = stepOptions.panStep;
31
34
  this.bearingStep = stepOptions.bearingStep;
32
35
  this.pitchStep = stepOptions.pitchStep;
33
36
  }
34
- _createClass(KeyboardHandler, [{
35
- key: "reset",
36
- value: function reset() {
37
- this.active = false;
37
+ reset() {
38
+ this.active = false;
39
+ }
40
+ keydown(e) {
41
+ if (e.altKey || e.ctrlKey || e.metaKey) {
42
+ return;
38
43
  }
39
- }, {
40
- key: "keydown",
41
- value: function keydown(e) {
42
- var _this = this;
43
- if (e.altKey || e.ctrlKey || e.metaKey) {
44
- return;
45
- }
46
- var zoomDir = 0;
47
- var bearingDir = 0;
48
- var pitchDir = 0;
49
- var xDir = 0;
50
- var yDir = 0;
51
- switch (e.keyCode) {
52
- case 61:
53
- case 107:
54
- case 171:
55
- case 187:
56
- zoomDir = 1;
57
- break;
58
- case 189:
59
- case 109:
60
- case 173:
61
- zoomDir = -1;
62
- break;
63
- case 37:
64
- if (e.shiftKey) {
65
- bearingDir = -1;
66
- } else {
67
- e.preventDefault();
68
- xDir = -1;
69
- }
70
- break;
71
- case 39:
72
- if (e.shiftKey) {
73
- bearingDir = 1;
74
- } else {
75
- e.preventDefault();
76
- xDir = 1;
77
- }
78
- break;
79
- case 38:
80
- if (e.shiftKey) {
81
- pitchDir = 1;
82
- } else {
83
- e.preventDefault();
84
- yDir = -1;
85
- }
86
- break;
87
- case 40:
88
- if (e.shiftKey) {
89
- pitchDir = -1;
90
- } else {
91
- e.preventDefault();
92
- yDir = 1;
93
- }
94
- break;
95
- default:
96
- return;
97
- }
98
- return {
99
- cameraAnimation: function cameraAnimation(map) {
100
- var zoom = map.getZoom();
101
- map.easeTo({
102
- duration: 300,
103
- easeId: 'keyboardHandler',
104
- easing: easeOut,
105
- zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
106
- bearing: map.getBearing() + bearingDir * _this.bearingStep,
107
- pitch: map.getPitch() + pitchDir * _this.pitchStep,
108
- offset: [-xDir * _this.panStep, -yDir * _this.panStep],
109
- center: map.getCenter()
110
- }, {
111
- originalEvent: e
112
- });
44
+ let zoomDir = 0;
45
+ let bearingDir = 0;
46
+ let pitchDir = 0;
47
+ let xDir = 0;
48
+ let yDir = 0;
49
+ switch (e.keyCode) {
50
+ case 61:
51
+ case 107:
52
+ case 171:
53
+ case 187:
54
+ zoomDir = 1;
55
+ break;
56
+ case 189:
57
+ case 109:
58
+ case 173:
59
+ zoomDir = -1;
60
+ break;
61
+ case 37:
62
+ if (e.shiftKey) {
63
+ bearingDir = -1;
64
+ } else {
65
+ e.preventDefault();
66
+ xDir = -1;
113
67
  }
114
- };
115
- }
116
- }, {
117
- key: "enable",
118
- value: function enable() {
119
- this.enabled = true;
120
- }
121
- }, {
122
- key: "disable",
123
- value: function disable() {
124
- this.enabled = false;
125
- this.reset();
126
- }
127
- }, {
128
- key: "isEnabled",
129
- value: function isEnabled() {
130
- return this.enabled;
131
- }
132
- }, {
133
- key: "isActive",
134
- value: function isActive() {
135
- return this.active;
68
+ break;
69
+ case 39:
70
+ if (e.shiftKey) {
71
+ bearingDir = 1;
72
+ } else {
73
+ e.preventDefault();
74
+ xDir = 1;
75
+ }
76
+ break;
77
+ case 38:
78
+ if (e.shiftKey) {
79
+ pitchDir = 1;
80
+ } else {
81
+ e.preventDefault();
82
+ yDir = -1;
83
+ }
84
+ break;
85
+ case 40:
86
+ if (e.shiftKey) {
87
+ pitchDir = -1;
88
+ } else {
89
+ e.preventDefault();
90
+ yDir = 1;
91
+ }
92
+ break;
93
+ default:
94
+ return;
136
95
  }
137
- }]);
138
- return KeyboardHandler;
139
- }();
96
+ return {
97
+ cameraAnimation: map => {
98
+ const zoom = map.getZoom();
99
+ map.easeTo({
100
+ duration: 300,
101
+ easeId: 'keyboardHandler',
102
+ easing: easeOut,
103
+ zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
104
+ bearing: map.getBearing() + bearingDir * this.bearingStep,
105
+ pitch: map.getPitch() + pitchDir * this.pitchStep,
106
+ offset: [-xDir * this.panStep, -yDir * this.panStep],
107
+ center: map.getCenter()
108
+ }, {
109
+ originalEvent: e
110
+ });
111
+ }
112
+ };
113
+ }
114
+ enable() {
115
+ this.enabled = true;
116
+ }
117
+ disable() {
118
+ this.enabled = false;
119
+ this.reset();
120
+ }
121
+ isEnabled() {
122
+ return this.enabled;
123
+ }
124
+ isActive() {
125
+ return this.active;
126
+ }
127
+ }
140
128
  function easeOut(t) {
141
129
  return t * (2 - t);
142
130
  }
@@ -1,125 +1,89 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
 
5
4
  import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from "./events";
6
- var MapEventHandler = /*#__PURE__*/function () {
7
- function MapEventHandler(map, options) {
8
- _classCallCheck(this, MapEventHandler);
5
+ export default class MapEventHandler {
6
+ constructor(map, options) {
7
+ _defineProperty(this, "mousedownPos", void 0);
8
+ _defineProperty(this, "clickTolerance", void 0);
9
+ _defineProperty(this, "map", void 0);
9
10
  this.map = map;
10
11
  this.clickTolerance = options.clickTolerance;
11
12
  }
12
- _createClass(MapEventHandler, [{
13
- key: "reset",
14
- value: function reset() {
15
- // @ts-ignore
16
- delete this.mousedownPos;
17
- }
18
- }, {
19
- key: "wheel",
20
- value: function wheel(e) {
21
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
22
- // - ScrollZoom
23
- return this.firePreventable(new MapWheelEvent(e.type, this.map, e));
24
- }
25
- }, {
26
- key: "mousedown",
27
- value: function mousedown(e, point) {
28
- this.mousedownPos = point;
29
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
30
- // - MousePan
31
- // - MouseRotate
32
- // - MousePitch
33
- // - DblclickHandler
34
- return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
35
- }
36
- }, {
37
- key: "mouseup",
38
- value: function mouseup(e) {
39
- this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
40
- }
41
- }, {
42
- key: "click",
43
- value: function click(e, point) {
44
- if (this.mousedownPos && this.mousedownPos.dist(point) >= this.clickTolerance) {
45
- return;
46
- }
47
- this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
48
- }
49
- }, {
50
- key: "dblclick",
51
- value: function dblclick(e) {
52
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
53
- // - DblClickZoom
54
- return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
55
- }
56
- }, {
57
- key: "mouseover",
58
- value: function mouseover(e) {
59
- this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
60
- }
61
- }, {
62
- key: "mouseout",
63
- value: function mouseout(e) {
64
- this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
65
- }
66
- }, {
67
- key: "touchstart",
68
- value: function touchstart(e) {
69
- // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
70
- // - TouchPan
71
- // - TouchZoom
72
- // - TouchRotate
73
- // - TouchPitch
74
- // - TapZoom
75
- // - SwipeZoom
76
- return this.firePreventable(new MapTouchEvent(e.type, this.map, e));
77
- }
78
- }, {
79
- key: "touchmove",
80
- value: function touchmove(e) {
81
- this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
82
- }
83
- }, {
84
- key: "touchend",
85
- value: function touchend(e) {
86
- this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
87
- }
88
- }, {
89
- key: "touchcancel",
90
- value: function touchcancel(e) {
91
- this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
92
- }
93
- }, {
94
- key: "firePreventable",
95
- value: function firePreventable(mapEvent) {
96
- this.map.emit(mapEvent.type, mapEvent);
97
- if (mapEvent.defaultPrevented) {
98
- // returning an object marks the handler as active and resets other handlers
99
- return {};
100
- }
101
- }
102
- }, {
103
- key: "isEnabled",
104
- value: function isEnabled() {
105
- return true;
106
- }
107
- }, {
108
- key: "isActive",
109
- value: function isActive() {
110
- return false;
111
- }
112
- }, {
113
- key: "enable",
114
- value: function enable() {
115
- return false;
13
+ reset() {
14
+ // @ts-ignore
15
+ delete this.mousedownPos;
16
+ }
17
+ wheel(e) {
18
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
19
+ // - ScrollZoom
20
+ return this.firePreventable(new MapWheelEvent(e.type, this.map, e));
21
+ }
22
+ mousedown(e, point) {
23
+ this.mousedownPos = point;
24
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
25
+ // - MousePan
26
+ // - MouseRotate
27
+ // - MousePitch
28
+ // - DblclickHandler
29
+ return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
30
+ }
31
+ mouseup(e) {
32
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
33
+ }
34
+ click(e, point) {
35
+ if (this.mousedownPos && this.mousedownPos.dist(point) >= this.clickTolerance) {
36
+ return;
116
37
  }
117
- }, {
118
- key: "disable",
119
- value: function disable() {
120
- return false;
38
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
39
+ }
40
+ dblclick(e) {
41
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
42
+ // - DblClickZoom
43
+ return this.firePreventable(new MapMouseEvent(e.type, this.map, e));
44
+ }
45
+ mouseover(e) {
46
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
47
+ }
48
+ mouseout(e) {
49
+ this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
50
+ }
51
+ touchstart(e) {
52
+ // If mapEvent.preventDefault() is called by the user, prevent handlers such as:
53
+ // - TouchPan
54
+ // - TouchZoom
55
+ // - TouchRotate
56
+ // - TouchPitch
57
+ // - TapZoom
58
+ // - SwipeZoom
59
+ return this.firePreventable(new MapTouchEvent(e.type, this.map, e));
60
+ }
61
+ touchmove(e) {
62
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
63
+ }
64
+ touchend(e) {
65
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
66
+ }
67
+ touchcancel(e) {
68
+ this.map.emit(e.type, new MapTouchEvent(e.type, this.map, e));
69
+ }
70
+ firePreventable(mapEvent) {
71
+ this.map.emit(mapEvent.type, mapEvent);
72
+ if (mapEvent.defaultPrevented) {
73
+ // returning an object marks the handler as active and resets other handlers
74
+ return {};
121
75
  }
122
- }]);
123
- return MapEventHandler;
124
- }();
125
- export { MapEventHandler as default };
76
+ }
77
+ isEnabled() {
78
+ return true;
79
+ }
80
+ isActive() {
81
+ return false;
82
+ }
83
+ enable() {
84
+ return false;
85
+ }
86
+ disable() {
87
+ return false;
88
+ }
89
+ }
@@ -1,118 +1,99 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  // @ts-ignore
4
3
 
5
4
  import DOM from "../../utils/dom";
6
5
  import { buttonStillPressed } from "./util";
7
- var MouseHandler = /*#__PURE__*/function () {
8
- function MouseHandler(options) {
9
- _classCallCheck(this, MouseHandler);
6
+ export default class MouseHandler {
7
+ constructor(options) {
8
+ _defineProperty(this, "enabled", void 0);
9
+ _defineProperty(this, "active", void 0);
10
+ _defineProperty(this, "lastPoint", void 0);
11
+ _defineProperty(this, "eventButton", void 0);
12
+ _defineProperty(this, "moved", void 0);
13
+ _defineProperty(this, "clickTolerance", void 0);
10
14
  this.reset();
11
15
  this.clickTolerance = options.clickTolerance || 1;
12
16
  }
13
- _createClass(MouseHandler, [{
14
- key: "reset",
15
- value: function reset() {
16
- this.active = false;
17
- this.moved = false;
18
- // @ts-ignore
19
- delete this.lastPoint;
20
- // @ts-ignore
21
- delete this.eventButton;
17
+ reset() {
18
+ this.active = false;
19
+ this.moved = false;
20
+ // @ts-ignore
21
+ delete this.lastPoint;
22
+ // @ts-ignore
23
+ delete this.eventButton;
24
+ }
25
+ mousedown(e, point) {
26
+ if (this.lastPoint) {
27
+ return;
22
28
  }
23
- }, {
24
- key: "mousedown",
25
- value: function mousedown(e, point) {
26
- if (this.lastPoint) {
27
- return;
28
- }
29
- var eventButton = DOM.mouseButton(e);
30
- if (!this.correctButton(e, eventButton)) {
31
- return;
32
- }
33
- this.lastPoint = point;
34
- this.eventButton = eventButton;
29
+ const eventButton = DOM.mouseButton(e);
30
+ if (!this.correctButton(e, eventButton)) {
31
+ return;
35
32
  }
36
- }, {
37
- key: "mousemoveWindow",
38
- value: function mousemoveWindow(e, point) {
39
- var lastPoint = this.lastPoint;
40
- if (!lastPoint) {
41
- return;
42
- }
43
- e.preventDefault();
44
- if (buttonStillPressed(e, this.eventButton)) {
45
- // Some browsers don't fire a `mouseup` when the mouseup occurs outside
46
- // the window or iframe:
47
- // https://github.com/mapbox/mapbox-gl-js/issues/4622
48
- //
49
- // If the button is no longer pressed during this `mousemove` it may have
50
- // been released outside of the window or iframe.
51
- this.reset();
52
- return;
53
- }
54
- if (!this.moved && point.dist(lastPoint) < this.clickTolerance) {
55
- return;
56
- }
57
- this.moved = true;
58
- this.lastPoint = point;
59
-
60
- // implemented by child class
61
- return this.move(lastPoint, point);
33
+ this.lastPoint = point;
34
+ this.eventButton = eventButton;
35
+ }
36
+ mousemoveWindow(e, point) {
37
+ const lastPoint = this.lastPoint;
38
+ if (!lastPoint) {
39
+ return;
62
40
  }
63
- }, {
64
- key: "mouseupWindow",
65
- value: function mouseupWindow(e) {
66
- if (!this.lastPoint) {
67
- return;
68
- }
69
- var eventButton = DOM.mouseButton(e);
70
- if (eventButton !== this.eventButton) {
71
- return;
72
- }
73
- if (this.moved) {
74
- DOM.suppressClick();
75
- }
41
+ e.preventDefault();
42
+ if (buttonStillPressed(e, this.eventButton)) {
43
+ // Some browsers don't fire a `mouseup` when the mouseup occurs outside
44
+ // the window or iframe:
45
+ // https://github.com/mapbox/mapbox-gl-js/issues/4622
46
+ //
47
+ // If the button is no longer pressed during this `mousemove` it may have
48
+ // been released outside of the window or iframe.
76
49
  this.reset();
50
+ return;
77
51
  }
78
- }, {
79
- key: "enable",
80
- value: function enable() {
81
- this.enabled = true;
52
+ if (!this.moved && point.dist(lastPoint) < this.clickTolerance) {
53
+ return;
82
54
  }
83
- }, {
84
- key: "disable",
85
- value: function disable() {
86
- this.enabled = false;
87
- this.reset();
55
+ this.moved = true;
56
+ this.lastPoint = point;
57
+
58
+ // implemented by child class
59
+ return this.move(lastPoint, point);
60
+ }
61
+ mouseupWindow(e) {
62
+ if (!this.lastPoint) {
63
+ return;
88
64
  }
89
- }, {
90
- key: "isEnabled",
91
- value: function isEnabled() {
92
- return this.enabled;
65
+ const eventButton = DOM.mouseButton(e);
66
+ if (eventButton !== this.eventButton) {
67
+ return;
93
68
  }
94
- }, {
95
- key: "isActive",
96
- value: function isActive() {
97
- return this.active;
69
+ if (this.moved) {
70
+ DOM.suppressClick();
98
71
  }
72
+ this.reset();
73
+ }
74
+ enable() {
75
+ this.enabled = true;
76
+ }
77
+ disable() {
78
+ this.enabled = false;
79
+ this.reset();
80
+ }
81
+ isEnabled() {
82
+ return this.enabled;
83
+ }
84
+ isActive() {
85
+ return this.active;
86
+ }
99
87
 
100
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
101
- }, {
102
- key: "correctButton",
103
- value: function correctButton(e, button) {
104
- // eslint-disable-line
105
- return false; // implemented by child
106
- }
88
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
89
+ correctButton(e, button) {
90
+ // eslint-disable-line
91
+ return false; // implemented by child
92
+ }
107
93
 
108
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
109
- }, {
110
- key: "move",
111
- value: function move(lastPoint, point) {
112
- // eslint-disable-line
113
- return; // implemented by child
114
- }
115
- }]);
116
- return MouseHandler;
117
- }();
118
- export { MouseHandler as default };
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
+ move(lastPoint, point) {
96
+ // eslint-disable-line
97
+ return; // implemented by child
98
+ }
99
+ }