@antv/l7-map 2.17.12 → 2.18.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 (168) hide show
  1. package/package.json +4 -4
  2. package/es/camera.d.ts +0 -85
  3. package/es/camera.js +0 -775
  4. package/es/css/l7.css +0 -98
  5. package/es/earthmap.d.ts +0 -66
  6. package/es/earthmap.js +0 -422
  7. package/es/geo/edge_insets.d.ts +0 -54
  8. package/es/geo/edge_insets.js +0 -118
  9. package/es/geo/lng_lat.d.ts +0 -18
  10. package/es/geo/lng_lat.js +0 -81
  11. package/es/geo/lng_lat_bounds.d.ts +0 -24
  12. package/es/geo/lng_lat_bounds.js +0 -167
  13. package/es/geo/mercator.d.ts +0 -29
  14. package/es/geo/mercator.js +0 -92
  15. package/es/geo/point.d.ts +0 -40
  16. package/es/geo/point.js +0 -231
  17. package/es/geo/simple.d.ts +0 -29
  18. package/es/geo/simple.js +0 -92
  19. package/es/geo/transform.d.ts +0 -198
  20. package/es/geo/transform.js +0 -971
  21. package/es/handler/IHandler.d.ts +0 -34
  22. package/es/handler/IHandler.js +0 -1
  23. package/es/handler/blockable_map_event.d.ts +0 -17
  24. package/es/handler/blockable_map_event.js +0 -83
  25. package/es/handler/box_zoom.d.ts +0 -59
  26. package/es/handler/box_zoom.js +0 -200
  27. package/es/handler/click_zoom.d.ts +0 -16
  28. package/es/handler/click_zoom.js +0 -59
  29. package/es/handler/events/event.d.ts +0 -4
  30. package/es/handler/events/event.js +0 -12
  31. package/es/handler/events/index.d.ts +0 -4
  32. package/es/handler/events/index.js +0 -4
  33. package/es/handler/events/map_mouse_event.d.ts +0 -34
  34. package/es/handler/events/map_mouse_event.js +0 -75
  35. package/es/handler/events/map_touch_event.d.ts +0 -57
  36. package/es/handler/events/map_touch_event.js +0 -105
  37. package/es/handler/events/map_wheel_event.d.ts +0 -33
  38. package/es/handler/events/map_wheel_event.js +0 -61
  39. package/es/handler/events/render_event.d.ts +0 -5
  40. package/es/handler/events/render_event.js +0 -39
  41. package/es/handler/handler_inertia.d.ts +0 -23
  42. package/es/handler/handler_inertia.js +0 -184
  43. package/es/handler/handler_manager.d.ts +0 -61
  44. package/es/handler/handler_manager.js +0 -684
  45. package/es/handler/handler_util.d.ts +0 -4
  46. package/es/handler/handler_util.js +0 -10
  47. package/es/handler/keyboard.d.ts +0 -36
  48. package/es/handler/keyboard.js +0 -162
  49. package/es/handler/map_event.d.ts +0 -29
  50. package/es/handler/map_event.js +0 -131
  51. package/es/handler/mouse/index.d.ts +0 -4
  52. package/es/handler/mouse/index.js +0 -4
  53. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  54. package/es/handler/mouse/mouse_handler.js +0 -131
  55. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  56. package/es/handler/mouse/mousepan_handler.js +0 -54
  57. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  58. package/es/handler/mouse/mousepitch_hander.js +0 -56
  59. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  60. package/es/handler/mouse/mouserotate_hander.js +0 -56
  61. package/es/handler/mouse/util.d.ts +0 -6
  62. package/es/handler/mouse/util.js +0 -12
  63. package/es/handler/scroll_zoom.d.ts +0 -93
  64. package/es/handler/scroll_zoom.js +0 -353
  65. package/es/handler/shim/dblclick_zoom.d.ts +0 -40
  66. package/es/handler/shim/dblclick_zoom.js +0 -72
  67. package/es/handler/shim/drag_pan.d.ts +0 -61
  68. package/es/handler/shim/drag_pan.js +0 -96
  69. package/es/handler/shim/drag_rotate.d.ts +0 -46
  70. package/es/handler/shim/drag_rotate.js +0 -80
  71. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  72. package/es/handler/shim/touch_zoom_rotate.js +0 -130
  73. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  74. package/es/handler/tap/single_tap_recognizer.js +0 -120
  75. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  76. package/es/handler/tap/tap_drag_zoom.js +0 -114
  77. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  78. package/es/handler/tap/tap_recognizer.js +0 -62
  79. package/es/handler/tap/tap_zoom.d.ts +0 -22
  80. package/es/handler/tap/tap_zoom.js +0 -115
  81. package/es/handler/touch/index.d.ts +0 -5
  82. package/es/handler/touch/index.js +0 -5
  83. package/es/handler/touch/touch_pan.d.ts +0 -30
  84. package/es/handler/touch/touch_pan.js +0 -128
  85. package/es/handler/touch/touch_pitch.d.ts +0 -13
  86. package/es/handler/touch/touch_pitch.js +0 -110
  87. package/es/handler/touch/touch_rotate.d.ts +0 -12
  88. package/es/handler/touch/touch_rotate.js +0 -88
  89. package/es/handler/touch/touch_zoom.d.ts +0 -12
  90. package/es/handler/touch/touch_zoom.js +0 -67
  91. package/es/handler/touch/two_touch.d.ts +0 -23
  92. package/es/handler/touch/two_touch.js +0 -138
  93. package/es/hash.d.ts +0 -14
  94. package/es/hash.js +0 -156
  95. package/es/index.d.ts +0 -4
  96. package/es/index.js +0 -4
  97. package/es/interface.d.ts +0 -34
  98. package/es/interface.js +0 -1
  99. package/es/map.d.ts +0 -70
  100. package/es/map.js +0 -464
  101. package/es/util.d.ts +0 -25
  102. package/es/util.js +0 -101
  103. package/es/utils/Aabb.d.ts +0 -12
  104. package/es/utils/Aabb.js +0 -133
  105. package/es/utils/dom.d.ts +0 -4
  106. package/es/utils/dom.js +0 -218
  107. package/es/utils/performance.d.ts +0 -17
  108. package/es/utils/performance.js +0 -62
  109. package/es/utils/primitives.d.ts +0 -6
  110. package/es/utils/primitives.js +0 -45
  111. package/es/utils/task_queue.d.ts +0 -13
  112. package/es/utils/task_queue.js +0 -106
  113. package/lib/camera.js +0 -801
  114. package/lib/css/l7.css +0 -98
  115. package/lib/earthmap.js +0 -445
  116. package/lib/geo/edge_insets.js +0 -129
  117. package/lib/geo/lng_lat.js +0 -94
  118. package/lib/geo/lng_lat_bounds.js +0 -177
  119. package/lib/geo/mercator.js +0 -121
  120. package/lib/geo/point.js +0 -239
  121. package/lib/geo/simple.js +0 -123
  122. package/lib/geo/transform.js +0 -1013
  123. package/lib/handler/IHandler.js +0 -5
  124. package/lib/handler/blockable_map_event.js +0 -92
  125. package/lib/handler/box_zoom.js +0 -217
  126. package/lib/handler/click_zoom.js +0 -67
  127. package/lib/handler/events/event.js +0 -23
  128. package/lib/handler/events/index.js +0 -31
  129. package/lib/handler/events/map_mouse_event.js +0 -87
  130. package/lib/handler/events/map_touch_event.js +0 -119
  131. package/lib/handler/events/map_wheel_event.js +0 -72
  132. package/lib/handler/events/render_event.js +0 -52
  133. package/lib/handler/handler_inertia.js +0 -193
  134. package/lib/handler/handler_manager.js +0 -714
  135. package/lib/handler/handler_util.js +0 -17
  136. package/lib/handler/keyboard.js +0 -172
  137. package/lib/handler/map_event.js +0 -140
  138. package/lib/handler/mouse/index.js +0 -31
  139. package/lib/handler/mouse/mouse_handler.js +0 -141
  140. package/lib/handler/mouse/mousepan_handler.js +0 -66
  141. package/lib/handler/mouse/mousepitch_hander.js +0 -67
  142. package/lib/handler/mouse/mouserotate_hander.js +0 -67
  143. package/lib/handler/mouse/util.js +0 -26
  144. package/lib/handler/scroll_zoom.js +0 -367
  145. package/lib/handler/shim/dblclick_zoom.js +0 -80
  146. package/lib/handler/shim/drag_pan.js +0 -105
  147. package/lib/handler/shim/drag_rotate.js +0 -88
  148. package/lib/handler/shim/touch_zoom_rotate.js +0 -139
  149. package/lib/handler/tap/single_tap_recognizer.js +0 -131
  150. package/lib/handler/tap/tap_drag_zoom.js +0 -124
  151. package/lib/handler/tap/tap_recognizer.js +0 -78
  152. package/lib/handler/tap/tap_zoom.js +0 -124
  153. package/lib/handler/touch/index.js +0 -39
  154. package/lib/handler/touch/touch_pan.js +0 -138
  155. package/lib/handler/touch/touch_pitch.js +0 -120
  156. package/lib/handler/touch/touch_rotate.js +0 -99
  157. package/lib/handler/touch/touch_zoom.js +0 -78
  158. package/lib/handler/touch/two_touch.js +0 -148
  159. package/lib/hash.js +0 -169
  160. package/lib/index.js +0 -57
  161. package/lib/interface.js +0 -5
  162. package/lib/map.js +0 -489
  163. package/lib/util.js +0 -135
  164. package/lib/utils/Aabb.js +0 -143
  165. package/lib/utils/dom.js +0 -233
  166. package/lib/utils/performance.js +0 -72
  167. package/lib/utils/primitives.js +0 -57
  168. package/lib/utils/task_queue.js +0 -115
@@ -1,56 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
- // @ts-ignore
12
- import MouseHandler from "./mouse_handler";
13
- import { LEFT_BUTTON, RIGHT_BUTTON } from "./util";
14
-
15
- var MouseRotateHandler = /*#__PURE__*/function (_MouseHandler) {
16
- _inherits(MouseRotateHandler, _MouseHandler);
17
-
18
- var _super = _createSuper(MouseRotateHandler);
19
-
20
- function MouseRotateHandler() {
21
- _classCallCheck(this, MouseRotateHandler);
22
-
23
- return _super.apply(this, arguments);
24
- }
25
-
26
- _createClass(MouseRotateHandler, [{
27
- key: "contextmenu",
28
- value: function contextmenu(e) {
29
- // prevent browser context menu when necessary; we don't allow it with rotation
30
- // because we can't discern rotation gesture start from contextmenu on Mac
31
- e.preventDefault();
32
- }
33
- }, {
34
- key: "correctButton",
35
- value: function correctButton(e, button) {
36
- return button === LEFT_BUTTON && e.ctrlKey || button === RIGHT_BUTTON;
37
- }
38
- }, {
39
- key: "move",
40
- value: function move(lastPoint, point) {
41
- var degreesPerPixelMoved = 0.8;
42
- var bearingDelta = (point.x - lastPoint.x) * degreesPerPixelMoved;
43
-
44
- if (bearingDelta) {
45
- this.active = true;
46
- return {
47
- bearingDelta: bearingDelta
48
- };
49
- }
50
- }
51
- }]);
52
-
53
- return MouseRotateHandler;
54
- }(MouseHandler);
55
-
56
- export { MouseRotateHandler as default };
@@ -1,6 +0,0 @@
1
- export declare const LEFT_BUTTON = 0;
2
- export declare const RIGHT_BUTTON = 2;
3
- export declare const BUTTONS_FLAGS: {
4
- [key: number]: number;
5
- };
6
- export declare function buttonStillPressed(e: MouseEvent, button: 1 | 2): boolean;
@@ -1,12 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- var _BUTTONS_FLAGS;
4
-
5
- export var LEFT_BUTTON = 0;
6
- export var RIGHT_BUTTON = 2; // the values for each button in MouseEvent.buttons
7
-
8
- export var BUTTONS_FLAGS = (_BUTTONS_FLAGS = {}, _defineProperty(_BUTTONS_FLAGS, LEFT_BUTTON, 1), _defineProperty(_BUTTONS_FLAGS, RIGHT_BUTTON, 2), _BUTTONS_FLAGS);
9
- export function buttonStillPressed(e, button) {
10
- var flag = BUTTONS_FLAGS[button];
11
- return e.buttons === undefined || (e.buttons & flag) !== flag;
12
- }
@@ -1,93 +0,0 @@
1
- import { EarthMap } from '../earthmap';
2
- import Point from '../geo/point';
3
- import { Map } from '../map';
4
- import HandlerManager from './handler_manager';
5
- /**
6
- * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
7
- */
8
- declare class ScrollZoomHandler {
9
- private map;
10
- private el;
11
- private enabled;
12
- private active;
13
- private zooming;
14
- private aroundCenter;
15
- private around;
16
- private aroundPoint;
17
- private type;
18
- private lastValue;
19
- private timeout;
20
- private finishTimeout;
21
- private lastWheelEvent;
22
- private lastWheelEventTime;
23
- private startZoom;
24
- private targetZoom;
25
- private delta;
26
- private easing;
27
- private prevEase;
28
- private frameId;
29
- private handler;
30
- private defaultZoomRate;
31
- private wheelZoomRate;
32
- /**
33
- * @private
34
- */
35
- constructor(map: Map | EarthMap, handler: HandlerManager);
36
- /**
37
- * Set the zoom rate of a trackpad
38
- * @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.
39
- * @example
40
- * // Speed up trackpad zoom
41
- * map.scrollZoom.setZoomRate(1/25);
42
- */
43
- setZoomRate(zoomRate: number): void;
44
- /**
45
- * Set the zoom rate of a mouse wheel
46
- * @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.
47
- * @example
48
- * // Slow down zoom of mouse wheel
49
- * map.scrollZoom.setWheelZoomRate(1/600);
50
- */
51
- setWheelZoomRate(zoomRate: number): void;
52
- /**
53
- * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
54
- *
55
- * @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
56
- */
57
- isEnabled(): boolean;
58
- isActive(): boolean;
59
- isZooming(): boolean;
60
- /**
61
- * Enables the "scroll to zoom" interaction.
62
- *
63
- * @param {Object} [options] Options object.
64
- * @param {string} [options.around] If "center" is passed, map will zoom around center of map
65
- *
66
- * @example
67
- * map.scrollZoom.enable();
68
- * @example
69
- * map.scrollZoom.enable({ around: 'center' })
70
- */
71
- enable(options?: any): void;
72
- /**
73
- * Disables the "scroll to zoom" interaction.
74
- *
75
- * @example
76
- * map.scrollZoom.disable();
77
- */
78
- disable(): void;
79
- wheel(e: WheelEvent): void;
80
- renderFrame(): {
81
- noInertia: boolean;
82
- needsRenderFrame: boolean;
83
- zoomDelta: number;
84
- around: Point;
85
- originalEvent: any;
86
- } | undefined;
87
- reset(): void;
88
- private onScrollFrame;
89
- private onTimeout;
90
- private start;
91
- private smoothOutEasing;
92
- }
93
- export default ScrollZoomHandler;
@@ -1,353 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
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
-
12
- var defaultZoomRate = 1 / 100;
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
-
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
24
-
25
- /**
26
- * @private
27
- */
28
- function ScrollZoomHandler(map, handler) {
29
- var _this = this;
30
-
31
- _classCallCheck(this, ScrollZoomHandler);
32
-
33
- _defineProperty(this, "onScrollFrame", function () {
34
- if (!_this.frameId) {
35
- return;
36
- }
37
-
38
- _this.frameId = null;
39
-
40
- if (!_this.isActive()) {
41
- return;
42
- }
43
-
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
46
-
47
- if (_this.delta !== 0) {
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
-
51
- var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(_this.delta * zoomRate)));
52
-
53
- if (_this.delta < 0 && scale !== 0) {
54
- scale = 1 / scale;
55
- }
56
-
57
- var fromScale = typeof _this.targetZoom === 'number' ? tr.zoomScale(_this.targetZoom) : tr.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
61
-
62
- if (_this.type === 'wheel') {
63
- _this.startZoom = tr.zoom;
64
- _this.easing = _this.smoothOutEasing(200);
65
- }
66
-
67
- _this.delta = 0;
68
- }
69
-
70
- var targetZoom = typeof _this.targetZoom === 'number' ? _this.targetZoom : tr.zoom;
71
- var startZoom = _this.startZoom;
72
- var easing = _this.easing;
73
- var finished = false;
74
- var zoom;
75
-
76
- if (_this.type === 'wheel' && startZoom && easing) {
77
- var t = Math.min((now() - _this.lastWheelEventTime) / 200, 1);
78
- var k = easing(t);
79
- zoom = interpolate(startZoom, targetZoom, k);
80
-
81
- if (t < 1) {
82
- if (!_this.frameId) {
83
- _this.frameId = true;
84
- }
85
- } else {
86
- finished = true;
87
- }
88
- } else {
89
- zoom = targetZoom;
90
- finished = true;
91
- }
92
-
93
- _this.active = true;
94
-
95
- if (finished) {
96
- _this.active = false; // @ts-ignore
97
-
98
- _this.finishTimeout = setTimeout(function () {
99
- _this.zooming = false;
100
-
101
- _this.handler.triggerRenderFrame(); // @ts-ignore
102
-
103
-
104
- delete _this.targetZoom; // @ts-ignore
105
-
106
- delete _this.finishTimeout;
107
- }, 200);
108
- }
109
-
110
- return {
111
- noInertia: true,
112
- needsRenderFrame: !finished,
113
- zoomDelta: zoom - tr.zoom,
114
- around: _this.aroundPoint,
115
- originalEvent: _this.lastWheelEvent
116
- };
117
- });
118
-
119
- this.map = map;
120
- this.el = map.getCanvasContainer();
121
- this.handler = handler;
122
- this.delta = 0;
123
- this.defaultZoomRate = defaultZoomRate;
124
- this.wheelZoomRate = wheelZoomRate;
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
-
134
-
135
- _createClass(ScrollZoomHandler, [{
136
- key: "setZoomRate",
137
- value: function setZoomRate(zoomRate) {
138
- this.defaultZoomRate = zoomRate;
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
-
148
- }, {
149
- key: "setWheelZoomRate",
150
- value: function setWheelZoomRate(zoomRate) {
151
- this.wheelZoomRate = zoomRate;
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
-
159
- }, {
160
- key: "isEnabled",
161
- value: function isEnabled() {
162
- return !!this.enabled;
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
-
170
- }, {
171
- key: "isActive",
172
- value: function isActive() {
173
- return !!this.active || this.finishTimeout !== undefined;
174
- }
175
- }, {
176
- key: "isZooming",
177
- value: function isZooming() {
178
- return !!this.zooming;
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
-
192
- }, {
193
- key: "enable",
194
- value: function enable(options) {
195
- if (this.isEnabled()) {
196
- return;
197
- }
198
-
199
- this.enabled = true;
200
- this.aroundCenter = options && options.around === 'center';
201
- }
202
- /**
203
- * Disables the "scroll to zoom" interaction.
204
- *
205
- * @example
206
- * map.scrollZoom.disable();
207
- */
208
-
209
- }, {
210
- key: "disable",
211
- value: function disable() {
212
- if (!this.isEnabled()) {
213
- return;
214
- }
215
-
216
- this.enabled = false;
217
- }
218
- }, {
219
- key: "wheel",
220
- value: function wheel(e) {
221
- if (!this.isEnabled()) {
222
- return;
223
- } // Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.
224
-
225
-
226
- var value = e.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;
227
- var nowTime = now();
228
- var timeDelta = nowTime - (this.lastWheelEventTime || 0);
229
- this.lastWheelEventTime = nowTime;
230
-
231
- if (value !== 0 && value % wheelZoomDelta === 0) {
232
- // This one is definitely a mouse wheel event.
233
- this.type = 'wheel';
234
- } else if (value !== 0 && Math.abs(value) < 4) {
235
- // This one is definitely a trackpad event because it is so small.
236
- this.type = 'trackpad';
237
- } else if (timeDelta > 400) {
238
- // This is likely a new scroll action.
239
- this.type = null;
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
-
243
- this.timeout = setTimeout(this.onTimeout, 40, e);
244
- } else if (!this.type) {
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.
249
-
250
- if (this.timeout) {
251
- clearTimeout(this.timeout);
252
- this.timeout = null;
253
- value += this.lastValue;
254
- }
255
- } // Slow down zoom if shift key is held for more precise zooming
256
-
257
-
258
- if (e.shiftKey && value) {
259
- value = value / 4;
260
- } // Only fire the callback if we actually know what type of scrolling device the user uses.
261
-
262
-
263
- if (this.type) {
264
- this.lastWheelEvent = e;
265
- this.delta -= value;
266
-
267
- if (!this.active) {
268
- this.start(e);
269
- }
270
- }
271
-
272
- e.preventDefault();
273
- }
274
- }, {
275
- key: "renderFrame",
276
- value: function renderFrame() {
277
- return this.onScrollFrame();
278
- }
279
- }, {
280
- key: "reset",
281
- value: function reset() {
282
- this.active = false;
283
- }
284
- }, {
285
- key: "onTimeout",
286
- value: function onTimeout(initialEvent) {
287
- this.type = 'wheel';
288
- this.delta -= this.lastValue;
289
-
290
- if (!this.active && this.start) {
291
- this.start(initialEvent);
292
- }
293
- }
294
- }, {
295
- key: "start",
296
- value: function start(e) {
297
- if (!this.delta) {
298
- return;
299
- }
300
-
301
- if (this.frameId) {
302
- this.frameId = null;
303
- }
304
-
305
- this.active = true;
306
-
307
- if (!this.isZooming()) {
308
- this.zooming = true;
309
- }
310
-
311
- if (this.finishTimeout) {
312
- clearTimeout(this.finishTimeout); // @ts-ignore
313
-
314
- delete this.finishTimeout;
315
- }
316
-
317
- var pos = DOM.mousePos(this.el, e);
318
- this.around = LngLat.convert(this.aroundCenter ? this.map.getCenter() : this.map.unproject(pos));
319
- this.aroundPoint = this.map.transform.locationPoint(this.around);
320
-
321
- if (!this.frameId) {
322
- this.frameId = true;
323
- this.handler.triggerRenderFrame();
324
- }
325
- }
326
- }, {
327
- key: "smoothOutEasing",
328
- value: function smoothOutEasing(duration) {
329
- var easing = ease;
330
-
331
- if (this.prevEase) {
332
- var preEase = this.prevEase;
333
- var t = (now() - preEase.start) / preEase.duration;
334
- var speed = preEase.easing(t + 0.01) - preEase.easing(t); // Quick hack to make new bezier that is continuous with last
335
-
336
- var x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
337
- var y = Math.sqrt(0.27 * 0.27 - x * x);
338
- easing = bezier(x, y, 0.25, 1);
339
- }
340
-
341
- this.prevEase = {
342
- start: now(),
343
- duration: duration,
344
- easing: easing
345
- };
346
- return easing;
347
- }
348
- }]);
349
-
350
- return ScrollZoomHandler;
351
- }();
352
-
353
- export default ScrollZoomHandler;
@@ -1,40 +0,0 @@
1
- import ClickZoomHandler from '../click_zoom';
2
- import TapZoomHandler from '../tap/tap_zoom';
3
- /**
4
- * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
5
- * double clicking or double tapping.
6
- */
7
- export default class DoubleClickZoomHandler {
8
- private clickZoom;
9
- private tapZoom;
10
- /**
11
- * @private
12
- */
13
- constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler);
14
- /**
15
- * Enables the "double click to zoom" interaction.
16
- *
17
- * @example
18
- * map.doubleClickZoom.enable();
19
- */
20
- enable(): void;
21
- /**
22
- * Disables the "double click to zoom" interaction.
23
- *
24
- * @example
25
- * map.doubleClickZoom.disable();
26
- */
27
- disable(): void;
28
- /**
29
- * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
30
- *
31
- * @returns {boolean} `true` if the "double click to zoom" interaction is enabled.
32
- */
33
- isEnabled(): boolean;
34
- /**
35
- * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
36
- *
37
- * @returns {boolean} `true` if the "double click to zoom" interaction is active.
38
- */
39
- isActive(): boolean;
40
- }
@@ -1,72 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
-
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
- */
12
- function DoubleClickZoomHandler(clickZoom, TapZoom) {
13
- _classCallCheck(this, DoubleClickZoomHandler);
14
-
15
- this.clickZoom = clickZoom;
16
- this.tapZoom = TapZoom;
17
- }
18
- /**
19
- * Enables the "double click to zoom" interaction.
20
- *
21
- * @example
22
- * map.doubleClickZoom.enable();
23
- */
24
-
25
-
26
- _createClass(DoubleClickZoomHandler, [{
27
- key: "enable",
28
- value: function enable() {
29
- this.clickZoom.enable();
30
- this.tapZoom.enable();
31
- }
32
- /**
33
- * Disables the "double click to zoom" interaction.
34
- *
35
- * @example
36
- * map.doubleClickZoom.disable();
37
- */
38
-
39
- }, {
40
- key: "disable",
41
- value: function disable() {
42
- this.clickZoom.disable();
43
- this.tapZoom.disable();
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
-
51
- }, {
52
- key: "isEnabled",
53
- value: function isEnabled() {
54
- return this.clickZoom.isEnabled() && this.tapZoom.isEnabled();
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
-
62
- }, {
63
- key: "isActive",
64
- value: function isActive() {
65
- return this.clickZoom.isActive() || this.tapZoom.isActive();
66
- }
67
- }]);
68
-
69
- return DoubleClickZoomHandler;
70
- }();
71
-
72
- export { DoubleClickZoomHandler as default };
@@ -1,61 +0,0 @@
1
- import { MousePanHandler } from '../mouse/';
2
- import { TouchPanHandler } from '../touch/';
3
- export interface IDragPanOptions {
4
- linearity?: number;
5
- easing?: (t: number) => number;
6
- deceleration?: number;
7
- maxSpeed?: number;
8
- }
9
- /**
10
- * The `DragPanHandler` allows the user to pan the map by clicking and dragging
11
- * the cursor.
12
- */
13
- export default class DragPanHandler {
14
- inertiaOptions: IDragPanOptions;
15
- private el;
16
- private mousePan;
17
- private touchPan;
18
- /**
19
- * @private
20
- */
21
- constructor(el: HTMLElement, mousePan: MousePanHandler, touchPan: TouchPanHandler);
22
- /**
23
- * Enables the "drag to pan" interaction.
24
- *
25
- * @param {Object} [options] Options object
26
- * @param {number} [options.linearity=0] factor used to scale the drag velocity
27
- * @param {Function} [options.easing=bezier(0, 0, 0.3, 1)] easing function applled to `map.panTo` when applying the drag.
28
- * @param {number} [options.maxSpeed=1400] the maximum value of the drag velocity.
29
- * @param {number} [options.deceleration=2500] the rate at which the speed reduces after the pan ends.
30
- *
31
- * @example
32
- * map.dragPan.enable();
33
- * @example
34
- * map.dragPan.enable({
35
- * linearity: 0.3,
36
- * easing: bezier(0, 0, 0.3, 1),
37
- * maxSpeed: 1400,
38
- * deceleration: 2500,
39
- * });
40
- */
41
- enable(options?: IDragPanOptions): void;
42
- /**
43
- * Disables the "drag to pan" interaction.
44
- *
45
- * @example
46
- * map.dragPan.disable();
47
- */
48
- disable(): void;
49
- /**
50
- * Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
51
- *
52
- * @returns {boolean} `true` if the "drag to pan" interaction is enabled.
53
- */
54
- isEnabled(): boolean;
55
- /**
56
- * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
57
- *
58
- * @returns {boolean} `true` if the "drag to pan" interaction is active.
59
- */
60
- isActive(): boolean;
61
- }