@antv/l7-map 2.9.20 → 2.9.22

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 (223) hide show
  1. package/es/camera.js +115 -85
  2. package/es/css/l7.css +98 -0
  3. package/es/earthmap.js +27 -43
  4. package/es/geo/edge_insets.js +44 -14
  5. package/es/geo/lng_lat.js +15 -11
  6. package/es/geo/lng_lat_bounds.js +6 -10
  7. package/es/geo/mercator.js +24 -12
  8. package/es/geo/point.js +2 -8
  9. package/es/geo/simple.js +24 -12
  10. package/es/geo/transform.js +421 -120
  11. package/es/handler/IHandler.js +1 -2
  12. package/es/handler/blockable_map_event.js +13 -14
  13. package/es/handler/box_zoom.js +43 -27
  14. package/es/handler/click_zoom.js +3 -8
  15. package/es/handler/events/event.js +3 -6
  16. package/es/handler/events/index.js +4 -5
  17. package/es/handler/events/map_mouse_event.js +30 -20
  18. package/es/handler/events/map_touch_event.js +55 -25
  19. package/es/handler/events/map_wheel_event.js +24 -15
  20. package/es/handler/events/render_event.js +3 -6
  21. package/es/handler/handler_inertia.js +10 -12
  22. package/es/handler/handler_manager.js +75 -72
  23. package/es/handler/handler_util.js +2 -2
  24. package/es/handler/keyboard.js +20 -15
  25. package/es/handler/map_event.js +23 -12
  26. package/es/handler/mouse/index.js +4 -5
  27. package/es/handler/mouse/mouse_handler.js +17 -21
  28. package/es/handler/mouse/mousepan_handler.js +5 -5
  29. package/es/handler/mouse/mousepitch_hander.js +7 -5
  30. package/es/handler/mouse/mouserotate_hander.js +7 -5
  31. package/es/handler/mouse/util.js +3 -3
  32. package/es/handler/scroll_zoom.js +103 -67
  33. package/es/handler/shim/dblclick_zoom.js +35 -8
  34. package/es/handler/shim/drag_pan.js +48 -12
  35. package/es/handler/shim/drag_rotate.js +39 -10
  36. package/es/handler/shim/touch_zoom_rotate.js +59 -16
  37. package/es/handler/tap/single_tap_recognizer.js +7 -17
  38. package/es/handler/tap/tap_drag_zoom.js +5 -18
  39. package/es/handler/tap/tap_recognizer.js +4 -15
  40. package/es/handler/tap/tap_zoom.js +4 -13
  41. package/es/handler/touch/index.js +5 -6
  42. package/es/handler/touch/touch_pan.js +9 -20
  43. package/es/handler/touch/touch_pitch.js +11 -23
  44. package/es/handler/touch/touch_rotate.js +15 -18
  45. package/es/handler/touch/touch_zoom.js +5 -19
  46. package/es/handler/touch/two_touch.js +14 -21
  47. package/es/hash.js +28 -16
  48. package/es/index.js +2 -3
  49. package/es/interface.js +1 -2
  50. package/es/map.js +26 -47
  51. package/es/util.js +15 -6
  52. package/es/utils/Aabb.js +11 -12
  53. package/es/utils/dom.js +30 -11
  54. package/es/utils/performance.js +10 -6
  55. package/es/utils/primitives.js +11 -10
  56. package/es/utils/task_queue.js +6 -13
  57. package/lib/camera.js +508 -721
  58. package/lib/css/l7.css +98 -0
  59. package/lib/earthmap.js +222 -392
  60. package/lib/geo/edge_insets.js +64 -83
  61. package/lib/geo/lng_lat.js +65 -81
  62. package/lib/geo/lng_lat_bounds.js +124 -165
  63. package/lib/geo/mercator.js +62 -78
  64. package/lib/geo/point.js +171 -239
  65. package/lib/geo/simple.js +61 -80
  66. package/lib/geo/transform.js +470 -653
  67. package/lib/handler/IHandler.js +17 -2
  68. package/lib/handler/blockable_map_event.js +63 -83
  69. package/lib/handler/box_zoom.js +123 -176
  70. package/lib/handler/click_zoom.js +56 -68
  71. package/lib/handler/events/event.js +35 -23
  72. package/lib/handler/events/index.js +35 -29
  73. package/lib/handler/events/map_mouse_event.js +42 -72
  74. package/lib/handler/events/map_touch_event.js +45 -80
  75. package/lib/handler/events/map_wheel_event.js +34 -58
  76. package/lib/handler/events/render_event.js +31 -52
  77. package/lib/handler/handler_inertia.js +113 -160
  78. package/lib/handler/handler_manager.js +379 -620
  79. package/lib/handler/handler_util.js +28 -10
  80. package/lib/handler/keyboard.js +114 -146
  81. package/lib/handler/map_event.js +84 -120
  82. package/lib/handler/mouse/index.js +35 -29
  83. package/lib/handler/mouse/mouse_handler.js +90 -123
  84. package/lib/handler/mouse/mousepan_handler.js +46 -65
  85. package/lib/handler/mouse/mousepitch_hander.js +44 -63
  86. package/lib/handler/mouse/mouserotate_hander.js +44 -63
  87. package/lib/handler/mouse/util.js +38 -20
  88. package/lib/handler/scroll_zoom.js +175 -258
  89. package/lib/handler/shim/dblclick_zoom.js +42 -48
  90. package/lib/handler/shim/drag_pan.js +48 -59
  91. package/lib/handler/shim/drag_rotate.js +43 -51
  92. package/lib/handler/shim/touch_zoom_rotate.js +58 -78
  93. package/lib/handler/tap/single_tap_recognizer.js +84 -117
  94. package/lib/handler/tap/tap_drag_zoom.js +92 -115
  95. package/lib/handler/tap/tap_recognizer.js +60 -78
  96. package/lib/handler/tap/tap_zoom.js +88 -119
  97. package/lib/handler/touch/index.js +38 -37
  98. package/lib/handler/touch/touch_pan.js +98 -132
  99. package/lib/handler/touch/touch_pitch.js +73 -117
  100. package/lib/handler/touch/touch_rotate.js +58 -94
  101. package/lib/handler/touch/touch_zoom.js +49 -84
  102. package/lib/handler/touch/two_touch.js +88 -128
  103. package/lib/hash.js +100 -133
  104. package/lib/index.js +19 -31
  105. package/lib/interface.js +17 -2
  106. package/lib/map.js +238 -420
  107. package/lib/util.js +67 -78
  108. package/lib/utils/Aabb.js +80 -132
  109. package/lib/utils/dom.js +84 -141
  110. package/lib/utils/performance.js +54 -42
  111. package/lib/utils/primitives.js +59 -51
  112. package/lib/utils/task_queue.js +61 -108
  113. package/package.json +11 -8
  114. package/es/camera.js.map +0 -1
  115. package/es/earthmap.js.map +0 -1
  116. package/es/geo/edge_insets.js.map +0 -1
  117. package/es/geo/lng_lat.js.map +0 -1
  118. package/es/geo/lng_lat_bounds.js.map +0 -1
  119. package/es/geo/mercator.js.map +0 -1
  120. package/es/geo/point.js.map +0 -1
  121. package/es/geo/simple.js.map +0 -1
  122. package/es/geo/transform.js.map +0 -1
  123. package/es/handler/IHandler.js.map +0 -1
  124. package/es/handler/blockable_map_event.js.map +0 -1
  125. package/es/handler/box_zoom.js.map +0 -1
  126. package/es/handler/click_zoom.js.map +0 -1
  127. package/es/handler/events/event.js.map +0 -1
  128. package/es/handler/events/index.js.map +0 -1
  129. package/es/handler/events/map_mouse_event.js.map +0 -1
  130. package/es/handler/events/map_touch_event.js.map +0 -1
  131. package/es/handler/events/map_wheel_event.js.map +0 -1
  132. package/es/handler/events/render_event.js.map +0 -1
  133. package/es/handler/handler_inertia.js.map +0 -1
  134. package/es/handler/handler_manager.js.map +0 -1
  135. package/es/handler/handler_util.js.map +0 -1
  136. package/es/handler/keyboard.js.map +0 -1
  137. package/es/handler/map_event.js.map +0 -1
  138. package/es/handler/mouse/index.js.map +0 -1
  139. package/es/handler/mouse/mouse_handler.js.map +0 -1
  140. package/es/handler/mouse/mousepan_handler.js.map +0 -1
  141. package/es/handler/mouse/mousepitch_hander.js.map +0 -1
  142. package/es/handler/mouse/mouserotate_hander.js.map +0 -1
  143. package/es/handler/mouse/util.js.map +0 -1
  144. package/es/handler/scroll_zoom.js.map +0 -1
  145. package/es/handler/shim/dblclick_zoom.js.map +0 -1
  146. package/es/handler/shim/drag_pan.js.map +0 -1
  147. package/es/handler/shim/drag_rotate.js.map +0 -1
  148. package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
  149. package/es/handler/tap/single_tap_recognizer.js.map +0 -1
  150. package/es/handler/tap/tap_drag_zoom.js.map +0 -1
  151. package/es/handler/tap/tap_recognizer.js.map +0 -1
  152. package/es/handler/tap/tap_zoom.js.map +0 -1
  153. package/es/handler/touch/index.js.map +0 -1
  154. package/es/handler/touch/touch_pan.js.map +0 -1
  155. package/es/handler/touch/touch_pitch.js.map +0 -1
  156. package/es/handler/touch/touch_rotate.js.map +0 -1
  157. package/es/handler/touch/touch_zoom.js.map +0 -1
  158. package/es/handler/touch/two_touch.js.map +0 -1
  159. package/es/hash.js.map +0 -1
  160. package/es/index.js.map +0 -1
  161. package/es/interface.js.map +0 -1
  162. package/es/map.js.map +0 -1
  163. package/es/util.js.map +0 -1
  164. package/es/utils/Aabb.js.map +0 -1
  165. package/es/utils/dom.js.map +0 -1
  166. package/es/utils/performance.js.map +0 -1
  167. package/es/utils/primitives.js.map +0 -1
  168. package/es/utils/task_queue.js.map +0 -1
  169. package/lib/camera.js.map +0 -1
  170. package/lib/earthmap.js.map +0 -1
  171. package/lib/geo/edge_insets.js.map +0 -1
  172. package/lib/geo/lng_lat.js.map +0 -1
  173. package/lib/geo/lng_lat_bounds.js.map +0 -1
  174. package/lib/geo/mercator.js.map +0 -1
  175. package/lib/geo/point.js.map +0 -1
  176. package/lib/geo/simple.js.map +0 -1
  177. package/lib/geo/transform.js.map +0 -1
  178. package/lib/handler/IHandler.js.map +0 -1
  179. package/lib/handler/blockable_map_event.js.map +0 -1
  180. package/lib/handler/box_zoom.js.map +0 -1
  181. package/lib/handler/click_zoom.js.map +0 -1
  182. package/lib/handler/events/event.js.map +0 -1
  183. package/lib/handler/events/index.js.map +0 -1
  184. package/lib/handler/events/map_mouse_event.js.map +0 -1
  185. package/lib/handler/events/map_touch_event.js.map +0 -1
  186. package/lib/handler/events/map_wheel_event.js.map +0 -1
  187. package/lib/handler/events/render_event.js.map +0 -1
  188. package/lib/handler/handler_inertia.js.map +0 -1
  189. package/lib/handler/handler_manager.js.map +0 -1
  190. package/lib/handler/handler_util.js.map +0 -1
  191. package/lib/handler/keyboard.js.map +0 -1
  192. package/lib/handler/map_event.js.map +0 -1
  193. package/lib/handler/mouse/index.js.map +0 -1
  194. package/lib/handler/mouse/mouse_handler.js.map +0 -1
  195. package/lib/handler/mouse/mousepan_handler.js.map +0 -1
  196. package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
  197. package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
  198. package/lib/handler/mouse/util.js.map +0 -1
  199. package/lib/handler/scroll_zoom.js.map +0 -1
  200. package/lib/handler/shim/dblclick_zoom.js.map +0 -1
  201. package/lib/handler/shim/drag_pan.js.map +0 -1
  202. package/lib/handler/shim/drag_rotate.js.map +0 -1
  203. package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
  204. package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
  205. package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
  206. package/lib/handler/tap/tap_recognizer.js.map +0 -1
  207. package/lib/handler/tap/tap_zoom.js.map +0 -1
  208. package/lib/handler/touch/index.js.map +0 -1
  209. package/lib/handler/touch/touch_pan.js.map +0 -1
  210. package/lib/handler/touch/touch_pitch.js.map +0 -1
  211. package/lib/handler/touch/touch_rotate.js.map +0 -1
  212. package/lib/handler/touch/touch_zoom.js.map +0 -1
  213. package/lib/handler/touch/two_touch.js.map +0 -1
  214. package/lib/hash.js.map +0 -1
  215. package/lib/index.js.map +0 -1
  216. package/lib/interface.js.map +0 -1
  217. package/lib/map.js.map +0 -1
  218. package/lib/util.js.map +0 -1
  219. package/lib/utils/Aabb.js.map +0 -1
  220. package/lib/utils/dom.js.map +0 -1
  221. package/lib/utils/performance.js.map +0 -1
  222. package/lib/utils/primitives.js.map +0 -1
  223. package/lib/utils/task_queue.js.map +0 -1
@@ -1,66 +1,35 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- import LngLat from '../geo/lng_lat';
5
- import { bezier, ease, interpolate, now } from '../util';
6
- import DOM from '../utils/dom';
7
- var wheelZoomDelta = 4.000244140625;
4
+ // @ts-ignore
5
+ import LngLat from "../geo/lng_lat";
6
+ import { bezier, ease, interpolate, now } from "../util";
7
+ import DOM from "../utils/dom";
8
+ // deltaY value for mouse scroll wheel identification
9
+ var wheelZoomDelta = 4.000244140625; // These magic numbers control the rate of zoom. Trackpad events fire at a greater
10
+ // frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick
11
+
8
12
  var defaultZoomRate = 1 / 100;
9
- var wheelZoomRate = 1 / 450;
13
+ var wheelZoomRate = 1 / 450; // upper bound on how much we scale the map in any single render frame; this
14
+ // is used to limit zoom rate in the case of very fast scrolling
15
+
10
16
  var maxScalePerFrame = 2;
17
+ /**
18
+ * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
19
+ */
20
+
21
+ var ScrollZoomHandler = /*#__PURE__*/function () {
22
+ // used for delayed-handling of a single wheel movement
23
+ // used to delay final '{move,zoom}end' events
11
24
 
12
- var ScrollZoomHandler = function () {
25
+ /**
26
+ * @private
27
+ */
13
28
  function ScrollZoomHandler(map, handler) {
14
29
  var _this = this;
15
30
 
16
31
  _classCallCheck(this, ScrollZoomHandler);
17
32
 
18
- _defineProperty(this, "map", void 0);
19
-
20
- _defineProperty(this, "el", void 0);
21
-
22
- _defineProperty(this, "enabled", void 0);
23
-
24
- _defineProperty(this, "active", void 0);
25
-
26
- _defineProperty(this, "zooming", void 0);
27
-
28
- _defineProperty(this, "aroundCenter", void 0);
29
-
30
- _defineProperty(this, "around", void 0);
31
-
32
- _defineProperty(this, "aroundPoint", void 0);
33
-
34
- _defineProperty(this, "type", void 0);
35
-
36
- _defineProperty(this, "lastValue", void 0);
37
-
38
- _defineProperty(this, "timeout", void 0);
39
-
40
- _defineProperty(this, "finishTimeout", void 0);
41
-
42
- _defineProperty(this, "lastWheelEvent", void 0);
43
-
44
- _defineProperty(this, "lastWheelEventTime", void 0);
45
-
46
- _defineProperty(this, "startZoom", void 0);
47
-
48
- _defineProperty(this, "targetZoom", void 0);
49
-
50
- _defineProperty(this, "delta", void 0);
51
-
52
- _defineProperty(this, "easing", void 0);
53
-
54
- _defineProperty(this, "prevEase", void 0);
55
-
56
- _defineProperty(this, "frameId", void 0);
57
-
58
- _defineProperty(this, "handler", void 0);
59
-
60
- _defineProperty(this, "defaultZoomRate", void 0);
61
-
62
- _defineProperty(this, "wheelZoomRate", void 0);
63
-
64
33
  _defineProperty(this, "onScrollFrame", function () {
65
34
  if (!_this.frameId) {
66
35
  return;
@@ -72,10 +41,13 @@ var ScrollZoomHandler = function () {
72
41
  return;
73
42
  }
74
43
 
75
- var tr = _this.map.transform;
44
+ var tr = _this.map.transform; // if we've had scroll events since the last render frame, consume the
45
+ // accumulated delta, and update the target zoom level accordingly
76
46
 
77
47
  if (_this.delta !== 0) {
78
- var zoomRate = _this.type === 'wheel' && Math.abs(_this.delta) > wheelZoomDelta ? _this.wheelZoomRate : _this.defaultZoomRate;
48
+ // For trackpad events and single mouse wheel ticks, use the default zoom rate
49
+ var zoomRate = _this.type === 'wheel' && Math.abs(_this.delta) > wheelZoomDelta ? _this.wheelZoomRate : _this.defaultZoomRate; // Scale by sigmoid of scroll wheel delta.
50
+
79
51
  var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(_this.delta * zoomRate)));
80
52
 
81
53
  if (_this.delta < 0 && scale !== 0) {
@@ -83,7 +55,9 @@ var ScrollZoomHandler = function () {
83
55
  }
84
56
 
85
57
  var fromScale = typeof _this.targetZoom === 'number' ? tr.zoomScale(_this.targetZoom) : tr.scale;
86
- _this.targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));
58
+ _this.targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale))); // if this is a mouse wheel, refresh the starting zoom and easing
59
+ // function we're using to smooth out the zooming between wheel
60
+ // events
87
61
 
88
62
  if (_this.type === 'wheel') {
89
63
  _this.startZoom = tr.zoom;
@@ -119,13 +93,16 @@ var ScrollZoomHandler = function () {
119
93
  _this.active = true;
120
94
 
121
95
  if (finished) {
122
- _this.active = false;
96
+ _this.active = false; // @ts-ignore
97
+
123
98
  _this.finishTimeout = setTimeout(function () {
124
99
  _this.zooming = false;
125
100
 
126
- _this.handler.triggerRenderFrame();
101
+ _this.handler.triggerRenderFrame(); // @ts-ignore
102
+
103
+
104
+ delete _this.targetZoom; // @ts-ignore
127
105
 
128
- delete _this.targetZoom;
129
106
  delete _this.finishTimeout;
130
107
  }, 200);
131
108
  }
@@ -146,22 +123,50 @@ var ScrollZoomHandler = function () {
146
123
  this.defaultZoomRate = defaultZoomRate;
147
124
  this.wheelZoomRate = wheelZoomRate;
148
125
  }
126
+ /**
127
+ * Set the zoom rate of a trackpad
128
+ * @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.
129
+ * @example
130
+ * // Speed up trackpad zoom
131
+ * map.scrollZoom.setZoomRate(1/25);
132
+ */
133
+
149
134
 
150
135
  _createClass(ScrollZoomHandler, [{
151
136
  key: "setZoomRate",
152
137
  value: function setZoomRate(zoomRate) {
153
138
  this.defaultZoomRate = zoomRate;
154
139
  }
140
+ /**
141
+ * Set the zoom rate of a mouse wheel
142
+ * @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.
143
+ * @example
144
+ * // Slow down zoom of mouse wheel
145
+ * map.scrollZoom.setWheelZoomRate(1/600);
146
+ */
147
+
155
148
  }, {
156
149
  key: "setWheelZoomRate",
157
150
  value: function setWheelZoomRate(zoomRate) {
158
151
  this.wheelZoomRate = zoomRate;
159
152
  }
153
+ /**
154
+ * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
155
+ *
156
+ * @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
157
+ */
158
+
160
159
  }, {
161
160
  key: "isEnabled",
162
161
  value: function isEnabled() {
163
162
  return !!this.enabled;
164
163
  }
164
+ /*
165
+ * Active state is turned on and off with every scroll wheel event and is set back to false before the map
166
+ * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in
167
+ * progress.
168
+ */
169
+
165
170
  }, {
166
171
  key: "isActive",
167
172
  value: function isActive() {
@@ -172,6 +177,18 @@ var ScrollZoomHandler = function () {
172
177
  value: function isZooming() {
173
178
  return !!this.zooming;
174
179
  }
180
+ /**
181
+ * Enables the "scroll to zoom" interaction.
182
+ *
183
+ * @param {Object} [options] Options object.
184
+ * @param {string} [options.around] If "center" is passed, map will zoom around center of map
185
+ *
186
+ * @example
187
+ * map.scrollZoom.enable();
188
+ * @example
189
+ * map.scrollZoom.enable({ around: 'center' })
190
+ */
191
+
175
192
  }, {
176
193
  key: "enable",
177
194
  value: function enable(options) {
@@ -182,6 +199,13 @@ var ScrollZoomHandler = function () {
182
199
  this.enabled = true;
183
200
  this.aroundCenter = options && options.around === 'center';
184
201
  }
202
+ /**
203
+ * Disables the "scroll to zoom" interaction.
204
+ *
205
+ * @example
206
+ * map.scrollZoom.disable();
207
+ */
208
+
185
209
  }, {
186
210
  key: "disable",
187
211
  value: function disable() {
@@ -196,7 +220,8 @@ var ScrollZoomHandler = function () {
196
220
  value: function wheel(e) {
197
221
  if (!this.isEnabled()) {
198
222
  return;
199
- }
223
+ } // Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.
224
+
200
225
 
201
226
  var value = e.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;
202
227
  var nowTime = now();
@@ -204,26 +229,36 @@ var ScrollZoomHandler = function () {
204
229
  this.lastWheelEventTime = nowTime;
205
230
 
206
231
  if (value !== 0 && value % wheelZoomDelta === 0) {
232
+ // This one is definitely a mouse wheel event.
207
233
  this.type = 'wheel';
208
234
  } else if (value !== 0 && Math.abs(value) < 4) {
235
+ // This one is definitely a trackpad event because it is so small.
209
236
  this.type = 'trackpad';
210
237
  } else if (timeDelta > 400) {
238
+ // This is likely a new scroll action.
211
239
  this.type = null;
212
- this.lastValue = value;
240
+ this.lastValue = value; // Start a timeout in case this was a singular event, and dely it by up to 40ms.
241
+ // @ts-ignore
242
+
213
243
  this.timeout = setTimeout(this.onTimeout, 40, e);
214
244
  } else if (!this.type) {
215
- this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel';
245
+ // This is a repeating event, but we don't know the type of event just yet.
246
+ // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.
247
+ this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel'; // Make sure our delayed event isn't fired again, because we accumulate
248
+ // the previous event (which was less than 40ms ago) into this event.
216
249
 
217
250
  if (this.timeout) {
218
251
  clearTimeout(this.timeout);
219
252
  this.timeout = null;
220
253
  value += this.lastValue;
221
254
  }
222
- }
255
+ } // Slow down zoom if shift key is held for more precise zooming
256
+
223
257
 
224
258
  if (e.shiftKey && value) {
225
259
  value = value / 4;
226
- }
260
+ } // Only fire the callback if we actually know what type of scrolling device the user uses.
261
+
227
262
 
228
263
  if (this.type) {
229
264
  this.lastWheelEvent = e;
@@ -274,7 +309,8 @@ var ScrollZoomHandler = function () {
274
309
  }
275
310
 
276
311
  if (this.finishTimeout) {
277
- clearTimeout(this.finishTimeout);
312
+ clearTimeout(this.finishTimeout); // @ts-ignore
313
+
278
314
  delete this.finishTimeout;
279
315
  }
280
316
 
@@ -295,7 +331,8 @@ var ScrollZoomHandler = function () {
295
331
  if (this.prevEase) {
296
332
  var preEase = this.prevEase;
297
333
  var t = (now() - preEase.start) / preEase.duration;
298
- var speed = preEase.easing(t + 0.01) - preEase.easing(t);
334
+ var speed = preEase.easing(t + 0.01) - preEase.easing(t); // Quick hack to make new bezier that is continuous with last
335
+
299
336
  var x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
300
337
  var y = Math.sqrt(0.27 * 0.27 - x * x);
301
338
  easing = bezier(x, y, 0.25, 1);
@@ -313,5 +350,4 @@ var ScrollZoomHandler = function () {
313
350
  return ScrollZoomHandler;
314
351
  }();
315
352
 
316
- export default ScrollZoomHandler;
317
- //# sourceMappingURL=scroll_zoom.js.map
353
+ export default ScrollZoomHandler;
@@ -1,18 +1,27 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
 
5
- var DoubleClickZoomHandler = function () {
4
+ /**
5
+ * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
6
+ * double clicking or double tapping.
7
+ */
8
+ var DoubleClickZoomHandler = /*#__PURE__*/function () {
9
+ /**
10
+ * @private
11
+ */
6
12
  function DoubleClickZoomHandler(clickZoom, TapZoom) {
7
13
  _classCallCheck(this, DoubleClickZoomHandler);
8
14
 
9
- _defineProperty(this, "clickZoom", void 0);
10
-
11
- _defineProperty(this, "tapZoom", void 0);
12
-
13
15
  this.clickZoom = clickZoom;
14
16
  this.tapZoom = TapZoom;
15
17
  }
18
+ /**
19
+ * Enables the "double click to zoom" interaction.
20
+ *
21
+ * @example
22
+ * map.doubleClickZoom.enable();
23
+ */
24
+
16
25
 
17
26
  _createClass(DoubleClickZoomHandler, [{
18
27
  key: "enable",
@@ -20,17 +29,36 @@ var DoubleClickZoomHandler = function () {
20
29
  this.clickZoom.enable();
21
30
  this.tapZoom.enable();
22
31
  }
32
+ /**
33
+ * Disables the "double click to zoom" interaction.
34
+ *
35
+ * @example
36
+ * map.doubleClickZoom.disable();
37
+ */
38
+
23
39
  }, {
24
40
  key: "disable",
25
41
  value: function disable() {
26
42
  this.clickZoom.disable();
27
43
  this.tapZoom.disable();
28
44
  }
45
+ /**
46
+ * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
47
+ *
48
+ * @returns {boolean} `true` if the "double click to zoom" interaction is enabled.
49
+ */
50
+
29
51
  }, {
30
52
  key: "isEnabled",
31
53
  value: function isEnabled() {
32
54
  return this.clickZoom.isEnabled() && this.tapZoom.isEnabled();
33
55
  }
56
+ /**
57
+ * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
58
+ *
59
+ * @returns {boolean} `true` if the "double click to zoom" interaction is active.
60
+ */
61
+
34
62
  }, {
35
63
  key: "isActive",
36
64
  value: function isActive() {
@@ -41,5 +69,4 @@ var DoubleClickZoomHandler = function () {
41
69
  return DoubleClickZoomHandler;
42
70
  }();
43
71
 
44
- export { DoubleClickZoomHandler as default };
45
- //# sourceMappingURL=dblclick_zoom.js.map
72
+ export { DoubleClickZoomHandler as default };
@@ -1,24 +1,42 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  import { isMini } from '@antv/l7-utils';
5
4
 
6
- var DragPanHandler = function () {
5
+ /**
6
+ * The `DragPanHandler` allows the user to pan the map by clicking and dragging
7
+ * the cursor.
8
+ */
9
+ var DragPanHandler = /*#__PURE__*/function () {
10
+ /**
11
+ * @private
12
+ */
7
13
  function DragPanHandler(el, mousePan, touchPan) {
8
14
  _classCallCheck(this, DragPanHandler);
9
15
 
10
- _defineProperty(this, "inertiaOptions", void 0);
11
-
12
- _defineProperty(this, "el", void 0);
13
-
14
- _defineProperty(this, "mousePan", void 0);
15
-
16
- _defineProperty(this, "touchPan", void 0);
17
-
18
16
  this.el = el;
19
17
  this.mousePan = mousePan;
20
18
  this.touchPan = touchPan;
21
19
  }
20
+ /**
21
+ * Enables the "drag to pan" interaction.
22
+ *
23
+ * @param {Object} [options] Options object
24
+ * @param {number} [options.linearity=0] factor used to scale the drag velocity
25
+ * @param {Function} [options.easing=bezier(0, 0, 0.3, 1)] easing function applled to `map.panTo` when applying the drag.
26
+ * @param {number} [options.maxSpeed=1400] the maximum value of the drag velocity.
27
+ * @param {number} [options.deceleration=2500] the rate at which the speed reduces after the pan ends.
28
+ *
29
+ * @example
30
+ * map.dragPan.enable();
31
+ * @example
32
+ * map.dragPan.enable({
33
+ * linearity: 0.3,
34
+ * easing: bezier(0, 0, 0.3, 1),
35
+ * maxSpeed: 1400,
36
+ * deceleration: 2500,
37
+ * });
38
+ */
39
+
22
40
 
23
41
  _createClass(DragPanHandler, [{
24
42
  key: "enable",
@@ -31,6 +49,13 @@ var DragPanHandler = function () {
31
49
  this.el.classList.add('l7-touch-drag-pan');
32
50
  }
33
51
  }
52
+ /**
53
+ * Disables the "drag to pan" interaction.
54
+ *
55
+ * @example
56
+ * map.dragPan.disable();
57
+ */
58
+
34
59
  }, {
35
60
  key: "disable",
36
61
  value: function disable() {
@@ -41,11 +66,23 @@ var DragPanHandler = function () {
41
66
  this.el.classList.remove('l7-touch-drag-pan');
42
67
  }
43
68
  }
69
+ /**
70
+ * Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
71
+ *
72
+ * @returns {boolean} `true` if the "drag to pan" interaction is enabled.
73
+ */
74
+
44
75
  }, {
45
76
  key: "isEnabled",
46
77
  value: function isEnabled() {
47
78
  return this.mousePan.isEnabled() && this.touchPan.isEnabled();
48
79
  }
80
+ /**
81
+ * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
82
+ *
83
+ * @returns {boolean} `true` if the "drag to pan" interaction is active.
84
+ */
85
+
49
86
  }, {
50
87
  key: "isActive",
51
88
  value: function isActive() {
@@ -56,5 +93,4 @@ var DragPanHandler = function () {
56
93
  return DragPanHandler;
57
94
  }();
58
95
 
59
- export { DragPanHandler as default };
60
- //# sourceMappingURL=drag_pan.js.map
96
+ export { DragPanHandler as default };
@@ -1,21 +1,32 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
 
5
- var DragRotateHandler = function () {
4
+ /**
5
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
6
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
7
+ */
8
+ var DragRotateHandler = /*#__PURE__*/function () {
9
+ /**
10
+ * @param {Object} [options]
11
+ * @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
12
+ * bearing will snap to north.
13
+ * @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
14
+ * @private
15
+ */
6
16
  function DragRotateHandler(options, mouseRotate, mousePitch) {
7
17
  _classCallCheck(this, DragRotateHandler);
8
18
 
9
- _defineProperty(this, "mouseRotate", void 0);
10
-
11
- _defineProperty(this, "mousePitch", void 0);
12
-
13
- _defineProperty(this, "pitchWithRotate", void 0);
14
-
15
19
  this.pitchWithRotate = options.pitchWithRotate;
16
20
  this.mouseRotate = mouseRotate;
17
21
  this.mousePitch = mousePitch;
18
22
  }
23
+ /**
24
+ * Enables the "drag to rotate" interaction.
25
+ *
26
+ * @example
27
+ * map.dragRotate.enable();
28
+ */
29
+
19
30
 
20
31
  _createClass(DragRotateHandler, [{
21
32
  key: "enable",
@@ -26,17 +37,36 @@ var DragRotateHandler = function () {
26
37
  this.mousePitch.enable();
27
38
  }
28
39
  }
40
+ /**
41
+ * Disables the "drag to rotate" interaction.
42
+ *
43
+ * @example
44
+ * map.dragRotate.disable();
45
+ */
46
+
29
47
  }, {
30
48
  key: "disable",
31
49
  value: function disable() {
32
50
  this.mouseRotate.disable();
33
51
  this.mousePitch.disable();
34
52
  }
53
+ /**
54
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
55
+ *
56
+ * @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
57
+ */
58
+
35
59
  }, {
36
60
  key: "isEnabled",
37
61
  value: function isEnabled() {
38
62
  return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
39
63
  }
64
+ /**
65
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
66
+ *
67
+ * @returns {boolean} `true` if the "drag to rotate" interaction is active.
68
+ */
69
+
40
70
  }, {
41
71
  key: "isActive",
42
72
  value: function isActive() {
@@ -47,5 +77,4 @@ var DragRotateHandler = function () {
47
77
  return DragRotateHandler;
48
78
  }();
49
79
 
50
- export { DragRotateHandler as default };
51
- //# sourceMappingURL=drag_rotate.js.map
80
+ export { DragRotateHandler as default };
@@ -1,24 +1,21 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  import { isMini } from '@antv/l7-utils';
5
4
 
6
- var TouchZoomRotateHandler = function () {
5
+ /**
6
+ * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
7
+ * pinching on a touchscreen.
8
+ *
9
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
10
+ * hold the finger down and drag up or down to zoom in or out.
11
+ */
12
+ var TouchZoomRotateHandler = /*#__PURE__*/function () {
13
+ /**
14
+ * @private
15
+ */
7
16
  function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
8
17
  _classCallCheck(this, TouchZoomRotateHandler);
9
18
 
10
- _defineProperty(this, "el", void 0);
11
-
12
- _defineProperty(this, "touchZoom", void 0);
13
-
14
- _defineProperty(this, "touchRotate", void 0);
15
-
16
- _defineProperty(this, "tapDragZoom", void 0);
17
-
18
- _defineProperty(this, "rotationDisabled", void 0);
19
-
20
- _defineProperty(this, "enabled", void 0);
21
-
22
19
  this.el = el;
23
20
  this.touchZoom = touchZoom;
24
21
  this.touchRotate = touchRotate;
@@ -26,6 +23,18 @@ var TouchZoomRotateHandler = function () {
26
23
  this.rotationDisabled = false;
27
24
  this.enabled = true;
28
25
  }
26
+ /**
27
+ * Enables the "pinch to rotate and zoom" interaction.
28
+ *
29
+ * @param {Object} [options] Options object.
30
+ * @param {string} [options.around] If "center" is passed, map will zoom around the center
31
+ *
32
+ * @example
33
+ * map.touchZoomRotate.enable();
34
+ * @example
35
+ * map.touchZoomRotate.enable({ around: 'center' });
36
+ */
37
+
29
38
 
30
39
  _createClass(TouchZoomRotateHandler, [{
31
40
  key: "enable",
@@ -42,6 +51,13 @@ var TouchZoomRotateHandler = function () {
42
51
  this.el.classList.add('l7-touch-zoom-rotate');
43
52
  }
44
53
  }
54
+ /**
55
+ * Disables the "pinch to rotate and zoom" interaction.
56
+ *
57
+ * @example
58
+ * map.touchZoomRotate.disable();
59
+ */
60
+
45
61
  }, {
46
62
  key: "disable",
47
63
  value: function disable() {
@@ -53,22 +69,50 @@ var TouchZoomRotateHandler = function () {
53
69
  this.el.classList.remove('l7-touch-zoom-rotate');
54
70
  }
55
71
  }
72
+ /**
73
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
74
+ *
75
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
76
+ */
77
+
56
78
  }, {
57
79
  key: "isEnabled",
58
80
  value: function isEnabled() {
59
81
  return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
60
82
  }
83
+ /**
84
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
85
+ *
86
+ * @returns {boolean} //eslint-disable-line
87
+ */
88
+
61
89
  }, {
62
90
  key: "isActive",
63
91
  value: function isActive() {
64
92
  return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
65
93
  }
94
+ /**
95
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
96
+ * interaction enabled.
97
+ *
98
+ * @example
99
+ * map.touchZoomRotate.disableRotation();
100
+ */
101
+
66
102
  }, {
67
103
  key: "disableRotation",
68
104
  value: function disableRotation() {
69
105
  this.rotationDisabled = true;
70
106
  this.touchRotate.disable();
71
107
  }
108
+ /**
109
+ * Enables the "pinch to rotate" interaction.
110
+ *
111
+ * @example
112
+ * map.touchZoomRotate.enable();
113
+ * map.touchZoomRotate.enableRotation();
114
+ */
115
+
72
116
  }, {
73
117
  key: "enableRotation",
74
118
  value: function enableRotation() {
@@ -83,5 +127,4 @@ var TouchZoomRotateHandler = function () {
83
127
  return TouchZoomRotateHandler;
84
128
  }();
85
129
 
86
- export { TouchZoomRotateHandler as default };
87
- //# sourceMappingURL=touch_zoom_rotate.js.map
130
+ export { TouchZoomRotateHandler as default };