@antv/l7-map 2.25.6 → 2.25.7

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 (159) hide show
  1. package/package.json +2 -2
  2. package/es/index.d.ts +0 -5
  3. package/es/index.js +0 -4
  4. package/es/map/camera.d.ts +0 -690
  5. package/es/map/camera.js +0 -1138
  6. package/es/map/css/l7.css +0 -171
  7. package/es/map/events.d.ts +0 -384
  8. package/es/map/events.js +0 -231
  9. package/es/map/geo/edge_insets.d.ts +0 -97
  10. package/es/map/geo/edge_insets.js +0 -115
  11. package/es/map/geo/lng_lat.d.ts +0 -116
  12. package/es/map/geo/lng_lat.js +0 -159
  13. package/es/map/geo/lng_lat_bounds.d.ts +0 -217
  14. package/es/map/geo/lng_lat_bounds.js +0 -334
  15. package/es/map/geo/mercator_coordinate.d.ts +0 -113
  16. package/es/map/geo/mercator_coordinate.js +0 -142
  17. package/es/map/geo/transform.d.ts +0 -262
  18. package/es/map/geo/transform.js +0 -736
  19. package/es/map/handler/box_zoom.d.ts +0 -65
  20. package/es/map/handler/box_zoom.js +0 -145
  21. package/es/map/handler/click_zoom.d.ts +0 -24
  22. package/es/map/handler/click_zoom.js +0 -47
  23. package/es/map/handler/cooperative_gestures.d.ts +0 -40
  24. package/es/map/handler/cooperative_gestures.js +0 -94
  25. package/es/map/handler/drag_handler.d.ts +0 -88
  26. package/es/map/handler/drag_handler.js +0 -89
  27. package/es/map/handler/drag_move_state_manager.d.ts +0 -30
  28. package/es/map/handler/drag_move_state_manager.js +0 -94
  29. package/es/map/handler/handler_util.d.ts +0 -3
  30. package/es/map/handler/handler_util.js +0 -8
  31. package/es/map/handler/keyboard.d.ts +0 -88
  32. package/es/map/handler/keyboard.js +0 -197
  33. package/es/map/handler/map_event.d.ts +0 -46
  34. package/es/map/handler/map_event.js +0 -131
  35. package/es/map/handler/mouse.d.ts +0 -30
  36. package/es/map/handler/mouse.js +0 -85
  37. package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
  38. package/es/map/handler/one_finger_touch_drag.js +0 -39
  39. package/es/map/handler/scroll_zoom.d.ts +0 -102
  40. package/es/map/handler/scroll_zoom.js +0 -312
  41. package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
  42. package/es/map/handler/shim/dblclick_zoom.js +0 -60
  43. package/es/map/handler/shim/drag_pan.d.ts +0 -79
  44. package/es/map/handler/shim/drag_pan.js +0 -77
  45. package/es/map/handler/shim/drag_rotate.d.ts +0 -54
  46. package/es/map/handler/shim/drag_rotate.js +0 -66
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
  48. package/es/map/handler/shim/two_fingers_touch.js +0 -106
  49. package/es/map/handler/tap_drag_zoom.d.ts +0 -28
  50. package/es/map/handler/tap_drag_zoom.js +0 -92
  51. package/es/map/handler/tap_recognizer.d.ts +0 -35
  52. package/es/map/handler/tap_recognizer.js +0 -107
  53. package/es/map/handler/tap_zoom.d.ts +0 -28
  54. package/es/map/handler/tap_zoom.js +0 -87
  55. package/es/map/handler/touch_pan.d.ts +0 -40
  56. package/es/map/handler/touch_pan.js +0 -85
  57. package/es/map/handler/transform-provider.d.ts +0 -23
  58. package/es/map/handler/transform-provider.js +0 -35
  59. package/es/map/handler/two_fingers_touch.d.ts +0 -107
  60. package/es/map/handler/two_fingers_touch.js +0 -289
  61. package/es/map/handler_inertia.d.ts +0 -20
  62. package/es/map/handler_inertia.js +0 -128
  63. package/es/map/handler_manager.d.ts +0 -154
  64. package/es/map/handler_manager.js +0 -466
  65. package/es/map/map.d.ts +0 -637
  66. package/es/map/map.js +0 -984
  67. package/es/map/util/abort_error.d.ts +0 -15
  68. package/es/map/util/abort_error.js +0 -21
  69. package/es/map/util/browser.d.ts +0 -10
  70. package/es/map/util/browser.js +0 -30
  71. package/es/map/util/dom.d.ts +0 -30
  72. package/es/map/util/dom.js +0 -105
  73. package/es/map/util/evented.d.ts +0 -75
  74. package/es/map/util/evented.js +0 -158
  75. package/es/map/util/simpleMapCoord.d.ts +0 -31
  76. package/es/map/util/simpleMapCoord.js +0 -54
  77. package/es/map/util/task_queue.d.ts +0 -18
  78. package/es/map/util/task_queue.js +0 -54
  79. package/es/map/util/util.d.ts +0 -104
  80. package/es/map/util/util.js +0 -155
  81. package/lib/index.d.ts +0 -5
  82. package/lib/index.js +0 -33
  83. package/lib/map/camera.d.ts +0 -690
  84. package/lib/map/camera.js +0 -1145
  85. package/lib/map/css/l7.css +0 -171
  86. package/lib/map/events.d.ts +0 -384
  87. package/lib/map/events.js +0 -240
  88. package/lib/map/geo/edge_insets.d.ts +0 -97
  89. package/lib/map/geo/edge_insets.js +0 -122
  90. package/lib/map/geo/lng_lat.d.ts +0 -116
  91. package/lib/map/geo/lng_lat.js +0 -166
  92. package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
  93. package/lib/map/geo/lng_lat_bounds.js +0 -341
  94. package/lib/map/geo/mercator_coordinate.d.ts +0 -113
  95. package/lib/map/geo/mercator_coordinate.js +0 -157
  96. package/lib/map/geo/transform.d.ts +0 -262
  97. package/lib/map/geo/transform.js +0 -744
  98. package/lib/map/handler/box_zoom.d.ts +0 -65
  99. package/lib/map/handler/box_zoom.js +0 -153
  100. package/lib/map/handler/click_zoom.d.ts +0 -24
  101. package/lib/map/handler/click_zoom.js +0 -54
  102. package/lib/map/handler/cooperative_gestures.d.ts +0 -40
  103. package/lib/map/handler/cooperative_gestures.js +0 -101
  104. package/lib/map/handler/drag_handler.d.ts +0 -88
  105. package/lib/map/handler/drag_handler.js +0 -97
  106. package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
  107. package/lib/map/handler/drag_move_state_manager.js +0 -103
  108. package/lib/map/handler/handler_util.d.ts +0 -3
  109. package/lib/map/handler/handler_util.js +0 -14
  110. package/lib/map/handler/keyboard.d.ts +0 -88
  111. package/lib/map/handler/keyboard.js +0 -205
  112. package/lib/map/handler/map_event.d.ts +0 -46
  113. package/lib/map/handler/map_event.js +0 -140
  114. package/lib/map/handler/mouse.d.ts +0 -30
  115. package/lib/map/handler/mouse.js +0 -93
  116. package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
  117. package/lib/map/handler/one_finger_touch_drag.js +0 -47
  118. package/lib/map/handler/scroll_zoom.d.ts +0 -102
  119. package/lib/map/handler/scroll_zoom.js +0 -320
  120. package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
  121. package/lib/map/handler/shim/dblclick_zoom.js +0 -68
  122. package/lib/map/handler/shim/drag_pan.d.ts +0 -79
  123. package/lib/map/handler/shim/drag_pan.js +0 -85
  124. package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
  125. package/lib/map/handler/shim/drag_rotate.js +0 -74
  126. package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
  127. package/lib/map/handler/shim/two_fingers_touch.js +0 -114
  128. package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
  129. package/lib/map/handler/tap_drag_zoom.js +0 -99
  130. package/lib/map/handler/tap_recognizer.d.ts +0 -35
  131. package/lib/map/handler/tap_recognizer.js +0 -116
  132. package/lib/map/handler/tap_zoom.d.ts +0 -28
  133. package/lib/map/handler/tap_zoom.js +0 -94
  134. package/lib/map/handler/touch_pan.d.ts +0 -40
  135. package/lib/map/handler/touch_pan.js +0 -92
  136. package/lib/map/handler/transform-provider.d.ts +0 -23
  137. package/lib/map/handler/transform-provider.js +0 -43
  138. package/lib/map/handler/two_fingers_touch.d.ts +0 -107
  139. package/lib/map/handler/two_fingers_touch.js +0 -296
  140. package/lib/map/handler_inertia.d.ts +0 -20
  141. package/lib/map/handler_inertia.js +0 -136
  142. package/lib/map/handler_manager.d.ts +0 -154
  143. package/lib/map/handler_manager.js +0 -474
  144. package/lib/map/map.d.ts +0 -637
  145. package/lib/map/map.js +0 -991
  146. package/lib/map/util/abort_error.d.ts +0 -15
  147. package/lib/map/util/abort_error.js +0 -29
  148. package/lib/map/util/browser.d.ts +0 -10
  149. package/lib/map/util/browser.js +0 -36
  150. package/lib/map/util/dom.d.ts +0 -30
  151. package/lib/map/util/dom.js +0 -113
  152. package/lib/map/util/evented.d.ts +0 -75
  153. package/lib/map/util/evented.js +0 -167
  154. package/lib/map/util/simpleMapCoord.d.ts +0 -31
  155. package/lib/map/util/simpleMapCoord.js +0 -62
  156. package/lib/map/util/task_queue.d.ts +0 -18
  157. package/lib/map/util/task_queue.js +0 -62
  158. package/lib/map/util/util.d.ts +0 -104
  159. package/lib/map/util/util.js +0 -171
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateMouseRotationHandler = exports.generateMousePitchHandler = exports.generateMousePanHandler = void 0;
7
- var _dom = require("../util/dom");
8
- var _drag_handler = require("./drag_handler");
9
- var _drag_move_state_manager = require("./drag_move_state_manager");
10
- /**
11
- * `MousePanHandler` allows the user to pan the map by clicking and dragging
12
- */
13
-
14
- /**
15
- * `MouseRotateHandler` allows the user to rotate the map by clicking and dragging
16
- */
17
-
18
- /**
19
- * `MousePitchHandler` allows the user to zoom the map by pitching
20
- */
21
-
22
- const LEFT_BUTTON = 0;
23
- const RIGHT_BUTTON = 2;
24
- const assignEvents = handler => {
25
- handler.mousedown = handler.dragStart;
26
- handler.mousemoveWindow = handler.dragMove;
27
- handler.mouseup = handler.dragEnd;
28
- handler.contextmenu = e => {
29
- e.preventDefault();
30
- };
31
- };
32
- const generateMousePanHandler = ({
33
- enable,
34
- clickTolerance
35
- }) => {
36
- const mouseMoveStateManager = new _drag_move_state_manager.MouseMoveStateManager({
37
- checkCorrectEvent: e => _dom.DOM.mouseButton(e) === LEFT_BUTTON && !e.ctrlKey
38
- });
39
- return new _drag_handler.DragHandler({
40
- clickTolerance,
41
- move: (lastPoint, point) => ({
42
- around: point,
43
- panDelta: point.sub(lastPoint)
44
- }),
45
- activateOnStart: true,
46
- moveStateManager: mouseMoveStateManager,
47
- enable,
48
- assignEvents
49
- });
50
- };
51
- exports.generateMousePanHandler = generateMousePanHandler;
52
- const generateMouseRotationHandler = ({
53
- enable,
54
- clickTolerance,
55
- bearingDegreesPerPixelMoved = 0.8
56
- }) => {
57
- const mouseMoveStateManager = new _drag_move_state_manager.MouseMoveStateManager({
58
- checkCorrectEvent: e => _dom.DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey || _dom.DOM.mouseButton(e) === RIGHT_BUTTON
59
- });
60
- return new _drag_handler.DragHandler({
61
- clickTolerance,
62
- move: (lastPoint, point) => ({
63
- bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved
64
- }),
65
- // prevent browser context menu when necessary; we don't allow it with rotation
66
- // because we can't discern rotation gesture start from contextmenu on Mac
67
- moveStateManager: mouseMoveStateManager,
68
- enable,
69
- assignEvents
70
- });
71
- };
72
- exports.generateMouseRotationHandler = generateMouseRotationHandler;
73
- const generateMousePitchHandler = ({
74
- enable,
75
- clickTolerance,
76
- pitchDegreesPerPixelMoved = -0.5
77
- }) => {
78
- const mouseMoveStateManager = new _drag_move_state_manager.MouseMoveStateManager({
79
- checkCorrectEvent: e => _dom.DOM.mouseButton(e) === LEFT_BUTTON && e.ctrlKey || _dom.DOM.mouseButton(e) === RIGHT_BUTTON
80
- });
81
- return new _drag_handler.DragHandler({
82
- clickTolerance,
83
- move: (lastPoint, point) => ({
84
- pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved
85
- }),
86
- // prevent browser context menu when necessary; we don't allow it with rotation
87
- // because we can't discern rotation gesture start from contextmenu on Mac
88
- moveStateManager: mouseMoveStateManager,
89
- enable,
90
- assignEvents
91
- });
92
- };
93
- exports.generateMousePitchHandler = generateMousePitchHandler;
@@ -1,15 +0,0 @@
1
- import type { DragMoveHandler, DragPitchResult, DragRotateResult } from './drag_handler';
2
- export interface OneFingerTouchRotateHandler extends DragMoveHandler<DragRotateResult, TouchEvent> {
3
- }
4
- export interface OneFingerTouchPitchHandler extends DragMoveHandler<DragPitchResult, TouchEvent> {
5
- }
6
- export declare const generateOneFingerTouchRotationHandler: ({ enable, clickTolerance, bearingDegreesPerPixelMoved, }: {
7
- clickTolerance: number;
8
- bearingDegreesPerPixelMoved?: number;
9
- enable?: boolean;
10
- }) => OneFingerTouchRotateHandler;
11
- export declare const generateOneFingerTouchPitchHandler: ({ enable, clickTolerance, pitchDegreesPerPixelMoved, }: {
12
- clickTolerance: number;
13
- pitchDegreesPerPixelMoved?: number;
14
- enable?: boolean;
15
- }) => OneFingerTouchPitchHandler;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateOneFingerTouchRotationHandler = exports.generateOneFingerTouchPitchHandler = void 0;
7
- var _drag_handler = require("./drag_handler");
8
- var _drag_move_state_manager = require("./drag_move_state_manager");
9
- const assignEvents = handler => {
10
- handler.touchstart = handler.dragStart;
11
- handler.touchmoveWindow = handler.dragMove;
12
- handler.touchend = handler.dragEnd;
13
- };
14
- const generateOneFingerTouchRotationHandler = ({
15
- enable,
16
- clickTolerance,
17
- bearingDegreesPerPixelMoved = 0.8
18
- }) => {
19
- const touchMoveStateManager = new _drag_move_state_manager.OneFingerTouchMoveStateManager();
20
- return new _drag_handler.DragHandler({
21
- clickTolerance,
22
- move: (lastPoint, point) => ({
23
- bearingDelta: (point.x - lastPoint.x) * bearingDegreesPerPixelMoved
24
- }),
25
- moveStateManager: touchMoveStateManager,
26
- enable,
27
- assignEvents
28
- });
29
- };
30
- exports.generateOneFingerTouchRotationHandler = generateOneFingerTouchRotationHandler;
31
- const generateOneFingerTouchPitchHandler = ({
32
- enable,
33
- clickTolerance,
34
- pitchDegreesPerPixelMoved = -0.5
35
- }) => {
36
- const touchMoveStateManager = new _drag_move_state_manager.OneFingerTouchMoveStateManager();
37
- return new _drag_handler.DragHandler({
38
- clickTolerance,
39
- move: (lastPoint, point) => ({
40
- pitchDelta: (point.y - lastPoint.y) * pitchDegreesPerPixelMoved
41
- }),
42
- moveStateManager: touchMoveStateManager,
43
- enable,
44
- assignEvents
45
- });
46
- };
47
- exports.generateOneFingerTouchPitchHandler = generateOneFingerTouchPitchHandler;
@@ -1,102 +0,0 @@
1
- /// <reference types="mapbox__point-geometry" />
2
- import { LngLat } from '../geo/lng_lat';
3
- import { TransformProvider } from './transform-provider';
4
- import type Point from '@mapbox/point-geometry';
5
- import type { Handler } from '../handler_manager';
6
- import type { Map } from '../map';
7
- import type { AroundCenterOptions } from './two_fingers_touch';
8
- /**
9
- * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
10
- *
11
- * @group Handlers
12
- */
13
- export declare class ScrollZoomHandler implements Handler {
14
- _map: Map;
15
- _tr: TransformProvider;
16
- _enabled: boolean;
17
- _active: boolean;
18
- _zooming: boolean;
19
- _aroundCenter: boolean;
20
- _around: LngLat;
21
- _aroundPoint: Point;
22
- _type: 'wheel' | 'trackpad' | null;
23
- _lastValue: number;
24
- _timeout: ReturnType<typeof setTimeout>;
25
- _finishTimeout: ReturnType<typeof setTimeout>;
26
- _lastWheelEvent: any;
27
- _lastWheelEventTime: number;
28
- _startZoom: number;
29
- _targetZoom: number;
30
- _delta: number;
31
- _easing: (a: number) => number;
32
- _prevEase: {
33
- start: number;
34
- duration: number;
35
- easing: (_: number) => number;
36
- };
37
- _frameId: boolean;
38
- _triggerRenderFrame: () => void;
39
- _defaultZoomRate: number;
40
- _wheelZoomRate: number;
41
- /** @internal */
42
- constructor(map: Map, triggerRenderFrame: () => void);
43
- /**
44
- * Set the zoom rate of a trackpad
45
- * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.
46
- * @example
47
- * Speed up trackpad zoom
48
- * ```ts
49
- * map.scrollZoom.setZoomRate(1/25);
50
- * ```
51
- */
52
- setZoomRate(zoomRate: number): void;
53
- /**
54
- * Set the zoom rate of a mouse wheel
55
- * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.
56
- * @example
57
- * Slow down zoom of mouse wheel
58
- * ```ts
59
- * map.scrollZoom.setWheelZoomRate(1/600);
60
- * ```
61
- */
62
- setWheelZoomRate(wheelZoomRate: number): void;
63
- /**
64
- * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
65
- * @returns `true` if the "scroll to zoom" interaction is enabled.
66
- */
67
- isEnabled(): boolean;
68
- isActive(): boolean;
69
- isZooming(): boolean;
70
- /**
71
- * Enables the "scroll to zoom" interaction.
72
- *
73
- * @param options - Options object.
74
- * @example
75
- * ```ts
76
- * map.scrollZoom.enable();
77
- * map.scrollZoom.enable({ around: 'center' })
78
- * ```
79
- */
80
- enable(options?: AroundCenterOptions | boolean): void;
81
- /**
82
- * Disables the "scroll to zoom" interaction.
83
- *
84
- * @example
85
- * ```ts
86
- * map.scrollZoom.disable();
87
- * ```
88
- */
89
- disable(): void;
90
- wheel(e: WheelEvent): void;
91
- _onTimeout: (initialEvent: MouseEvent) => void;
92
- _start(e: MouseEvent): void;
93
- renderFrame(): {
94
- noInertia: boolean;
95
- needsRenderFrame: boolean;
96
- zoomDelta: number;
97
- around: Point;
98
- originalEvent: any;
99
- };
100
- _smoothOutEasing(duration: number): (t: number) => number;
101
- reset(): void;
102
- }
@@ -1,320 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ScrollZoomHandler = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _dom = require("../util/dom");
10
- var _lng_lat = require("../geo/lng_lat");
11
- var _browser = require("../util/browser");
12
- var _util = require("../util/util");
13
- var _transformProvider = require("./transform-provider");
14
- // deltaY value for mouse scroll wheel identification
15
- const wheelZoomDelta = 4.000244140625;
16
-
17
- // These magic numbers control the rate of zoom. Trackpad events fire at a greater
18
- // frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick
19
- const defaultZoomRate = 1 / 100;
20
- const wheelZoomRate = 1 / 450;
21
-
22
- // upper bound on how much we scale the map in any single render frame; this
23
- // is used to limit zoom rate in the case of very fast scrolling
24
- const maxScalePerFrame = 2;
25
-
26
- /**
27
- * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
28
- *
29
- * @group Handlers
30
- */
31
- class ScrollZoomHandler {
32
- /** @internal */
33
- constructor(map, triggerRenderFrame) {
34
- (0, _defineProperty2.default)(this, "_map", void 0);
35
- (0, _defineProperty2.default)(this, "_tr", void 0);
36
- (0, _defineProperty2.default)(this, "_enabled", void 0);
37
- (0, _defineProperty2.default)(this, "_active", void 0);
38
- (0, _defineProperty2.default)(this, "_zooming", void 0);
39
- (0, _defineProperty2.default)(this, "_aroundCenter", void 0);
40
- (0, _defineProperty2.default)(this, "_around", void 0);
41
- (0, _defineProperty2.default)(this, "_aroundPoint", void 0);
42
- (0, _defineProperty2.default)(this, "_type", void 0);
43
- (0, _defineProperty2.default)(this, "_lastValue", void 0);
44
- (0, _defineProperty2.default)(this, "_timeout", void 0);
45
- // used for delayed-handling of a single wheel movement
46
- (0, _defineProperty2.default)(this, "_finishTimeout", void 0);
47
- // used to delay final '{move,zoom}end' events
48
- (0, _defineProperty2.default)(this, "_lastWheelEvent", void 0);
49
- (0, _defineProperty2.default)(this, "_lastWheelEventTime", void 0);
50
- (0, _defineProperty2.default)(this, "_startZoom", void 0);
51
- (0, _defineProperty2.default)(this, "_targetZoom", void 0);
52
- (0, _defineProperty2.default)(this, "_delta", void 0);
53
- (0, _defineProperty2.default)(this, "_easing", void 0);
54
- (0, _defineProperty2.default)(this, "_prevEase", void 0);
55
- (0, _defineProperty2.default)(this, "_frameId", void 0);
56
- (0, _defineProperty2.default)(this, "_triggerRenderFrame", void 0);
57
- (0, _defineProperty2.default)(this, "_defaultZoomRate", void 0);
58
- (0, _defineProperty2.default)(this, "_wheelZoomRate", void 0);
59
- (0, _defineProperty2.default)(this, "_onTimeout", initialEvent => {
60
- this._type = 'wheel';
61
- this._delta -= this._lastValue;
62
- if (!this._active) {
63
- this._start(initialEvent);
64
- }
65
- });
66
- this._map = map;
67
- this._tr = new _transformProvider.TransformProvider(map);
68
- this._triggerRenderFrame = triggerRenderFrame;
69
- this._delta = 0;
70
- this._defaultZoomRate = defaultZoomRate;
71
- this._wheelZoomRate = wheelZoomRate;
72
- }
73
-
74
- /**
75
- * Set the zoom rate of a trackpad
76
- * @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.
77
- * @example
78
- * Speed up trackpad zoom
79
- * ```ts
80
- * map.scrollZoom.setZoomRate(1/25);
81
- * ```
82
- */
83
- setZoomRate(zoomRate) {
84
- this._defaultZoomRate = zoomRate;
85
- }
86
-
87
- /**
88
- * Set the zoom rate of a mouse wheel
89
- * @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.
90
- * @example
91
- * Slow down zoom of mouse wheel
92
- * ```ts
93
- * map.scrollZoom.setWheelZoomRate(1/600);
94
- * ```
95
- */
96
- setWheelZoomRate(wheelZoomRate) {
97
- this._wheelZoomRate = wheelZoomRate;
98
- }
99
-
100
- /**
101
- * Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
102
- * @returns `true` if the "scroll to zoom" interaction is enabled.
103
- */
104
- isEnabled() {
105
- return !!this._enabled;
106
- }
107
-
108
- /*
109
- * Active state is turned on and off with every scroll wheel event and is set back to false before the map
110
- * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in
111
- * progress.
112
- */
113
- isActive() {
114
- return !!this._active || this._finishTimeout !== undefined;
115
- }
116
- isZooming() {
117
- return !!this._zooming;
118
- }
119
-
120
- /**
121
- * Enables the "scroll to zoom" interaction.
122
- *
123
- * @param options - Options object.
124
- * @example
125
- * ```ts
126
- * map.scrollZoom.enable();
127
- * map.scrollZoom.enable({ around: 'center' })
128
- * ```
129
- */
130
- enable(options) {
131
- if (this.isEnabled()) return;
132
- this._enabled = true;
133
- this._aroundCenter = !!options && options.around === 'center';
134
- }
135
-
136
- /**
137
- * Disables the "scroll to zoom" interaction.
138
- *
139
- * @example
140
- * ```ts
141
- * map.scrollZoom.disable();
142
- * ```
143
- */
144
- disable() {
145
- if (!this.isEnabled()) return;
146
- this._enabled = false;
147
- }
148
- wheel(e) {
149
- if (!this.isEnabled()) return;
150
- if (this._map.cooperativeGestures.isEnabled() && !e[this._map.cooperativeGestures._bypassKey]) {
151
- return;
152
- }
153
- let value = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;
154
- const now = _browser.browser.now(),
155
- timeDelta = now - (this._lastWheelEventTime || 0);
156
- this._lastWheelEventTime = now;
157
- if (value !== 0 && value % wheelZoomDelta === 0) {
158
- // This one is definitely a mouse wheel event.
159
- this._type = 'wheel';
160
- } else if (value !== 0 && Math.abs(value) < 4) {
161
- // This one is definitely a trackpad event because it is so small.
162
- this._type = 'trackpad';
163
- } else if (timeDelta > 400) {
164
- // This is likely a new scroll action.
165
- this._type = null;
166
- this._lastValue = value;
167
-
168
- // Start a timeout in case this was a singular event, and dely it by up to 40ms.
169
- this._timeout = setTimeout(this._onTimeout, 40, e);
170
- } else if (!this._type) {
171
- // This is a repeating event, but we don't know the type of event just yet.
172
- // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.
173
- this._type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel';
174
-
175
- // Make sure our delayed event isn't fired again, because we accumulate
176
- // the previous event (which was less than 40ms ago) into this event.
177
- if (this._timeout) {
178
- clearTimeout(this._timeout);
179
- this._timeout = null;
180
- value += this._lastValue;
181
- }
182
- }
183
-
184
- // Slow down zoom if shift key is held for more precise zooming
185
- if (e.shiftKey && value) value = value / 4;
186
-
187
- // Only fire the callback if we actually know what type of scrolling device the user uses.
188
- if (this._type) {
189
- this._lastWheelEvent = e;
190
- this._delta -= value;
191
- if (!this._active) {
192
- this._start(e);
193
- }
194
- }
195
- e.preventDefault();
196
- }
197
- _start(e) {
198
- if (!this._delta) return;
199
- if (this._frameId) {
200
- this._frameId = null;
201
- }
202
- this._active = true;
203
- if (!this.isZooming()) {
204
- this._zooming = true;
205
- }
206
- if (this._finishTimeout) {
207
- clearTimeout(this._finishTimeout);
208
- delete this._finishTimeout;
209
- }
210
- const pos = _dom.DOM.mousePos(this._map.getCanvasContainer(), e);
211
- const tr = this._tr;
212
- if (pos.y > tr.transform.height / 2 - tr.transform.getHorizon()) {
213
- this._around = _lng_lat.LngLat.convert(this._aroundCenter ? tr.center : tr.unproject(pos));
214
- } else {
215
- // Do not use current cursor position if above the horizon to avoid 'unproject' this point
216
- // as it is not mapped into 'coords' framebuffer or inversible with 'pixelMatrixInverse'.
217
- this._around = _lng_lat.LngLat.convert(tr.center);
218
- }
219
- this._aroundPoint = tr.transform.locationPoint(this._around);
220
- if (!this._frameId) {
221
- this._frameId = true;
222
- this._triggerRenderFrame();
223
- }
224
- }
225
- renderFrame() {
226
- if (!this._frameId) return;
227
- this._frameId = null;
228
- if (!this.isActive()) return;
229
- const tr = this._tr.transform;
230
-
231
- // if we've had scroll events since the last render frame, consume the
232
- // accumulated delta, and update the target zoom level accordingly
233
- if (this._delta !== 0) {
234
- // For trackpad events and single mouse wheel ticks, use the default zoom rate
235
- const zoomRate = this._type === 'wheel' && Math.abs(this._delta) > wheelZoomDelta ? this._wheelZoomRate : this._defaultZoomRate;
236
- // Scale by sigmoid of scroll wheel delta.
237
- let scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));
238
- if (this._delta < 0 && scale !== 0) {
239
- scale = 1 / scale;
240
- }
241
- const fromScale = typeof this._targetZoom === 'number' ? tr.zoomScale(this._targetZoom) : tr.scale;
242
- this._targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));
243
-
244
- // if this is a mouse wheel, refresh the starting zoom and easing
245
- // function we're using to smooth out the zooming between wheel
246
- // events
247
- if (this._type === 'wheel') {
248
- this._startZoom = tr.zoom;
249
- this._easing = this._smoothOutEasing(200);
250
- }
251
- this._delta = 0;
252
- }
253
- const targetZoom = typeof this._targetZoom === 'number' ? this._targetZoom : tr.zoom;
254
- const startZoom = this._startZoom;
255
- const easing = this._easing;
256
- let finished = false;
257
- let zoom;
258
- if (this._type === 'wheel' && startZoom && easing) {
259
- const t = Math.min((_browser.browser.now() - this._lastWheelEventTime) / 200, 1);
260
- const k = easing(t);
261
- zoom = _util.interpolates.number(startZoom, targetZoom, k);
262
- if (t < 1) {
263
- if (!this._frameId) {
264
- this._frameId = true;
265
- }
266
- } else {
267
- finished = true;
268
- }
269
- } else {
270
- zoom = targetZoom;
271
- finished = true;
272
- }
273
- this._active = true;
274
- if (finished) {
275
- this._active = false;
276
- this._finishTimeout = setTimeout(() => {
277
- this._zooming = false;
278
- this._triggerRenderFrame();
279
- delete this._targetZoom;
280
- delete this._finishTimeout;
281
- }, 200);
282
- }
283
- return {
284
- noInertia: true,
285
- needsRenderFrame: !finished,
286
- zoomDelta: zoom - tr.zoom,
287
- around: this._aroundPoint,
288
- originalEvent: this._lastWheelEvent
289
- };
290
- }
291
- _smoothOutEasing(duration) {
292
- let easing = _util.defaultEasing;
293
- if (this._prevEase) {
294
- const currentEase = this._prevEase;
295
- const t = (_browser.browser.now() - currentEase.start) / currentEase.duration;
296
- const speed = currentEase.easing(t + 0.01) - currentEase.easing(t);
297
-
298
- // Quick hack to make new bezier that is continuous with last
299
- const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
300
- const y = Math.sqrt(0.27 * 0.27 - x * x);
301
- easing = (0, _util.bezier)(x, y, 0.25, 1);
302
- }
303
- this._prevEase = {
304
- start: _browser.browser.now(),
305
- duration,
306
- easing
307
- };
308
- return easing;
309
- }
310
- reset() {
311
- this._active = false;
312
- this._zooming = false;
313
- delete this._targetZoom;
314
- if (this._finishTimeout) {
315
- clearTimeout(this._finishTimeout);
316
- delete this._finishTimeout;
317
- }
318
- }
319
- }
320
- exports.ScrollZoomHandler = ScrollZoomHandler;
@@ -1,44 +0,0 @@
1
- import type { ClickZoomHandler } from '../click_zoom';
2
- import type { TapZoomHandler } from '../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
- * @group Handlers
8
- */
9
- export declare class DoubleClickZoomHandler {
10
- _clickZoom: ClickZoomHandler;
11
- _tapZoom: TapZoomHandler;
12
- /** @internal */
13
- constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler);
14
- /**
15
- * Enables the "double click to zoom" interaction.
16
- *
17
- * @example
18
- * ```ts
19
- * map.doubleClickZoom.enable();
20
- * ```
21
- */
22
- enable(): void;
23
- /**
24
- * Disables the "double click to zoom" interaction.
25
- *
26
- * @example
27
- * ```ts
28
- * map.doubleClickZoom.disable();
29
- * ```
30
- */
31
- disable(): void;
32
- /**
33
- * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
34
- *
35
- * @returns `true` if the "double click to zoom" interaction is enabled.
36
- */
37
- isEnabled(): boolean;
38
- /**
39
- * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
40
- *
41
- * @returns `true` if the "double click to zoom" interaction is active.
42
- */
43
- isActive(): boolean;
44
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DoubleClickZoomHandler = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- /**
10
- * The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
11
- * double clicking or double tapping.
12
- *
13
- * @group Handlers
14
- */
15
- class DoubleClickZoomHandler {
16
- /** @internal */
17
- constructor(clickZoom, TapZoom) {
18
- (0, _defineProperty2.default)(this, "_clickZoom", void 0);
19
- (0, _defineProperty2.default)(this, "_tapZoom", void 0);
20
- this._clickZoom = clickZoom;
21
- this._tapZoom = TapZoom;
22
- }
23
-
24
- /**
25
- * Enables the "double click to zoom" interaction.
26
- *
27
- * @example
28
- * ```ts
29
- * map.doubleClickZoom.enable();
30
- * ```
31
- */
32
- enable() {
33
- this._clickZoom.enable();
34
- this._tapZoom.enable();
35
- }
36
-
37
- /**
38
- * Disables the "double click to zoom" interaction.
39
- *
40
- * @example
41
- * ```ts
42
- * map.doubleClickZoom.disable();
43
- * ```
44
- */
45
- disable() {
46
- this._clickZoom.disable();
47
- this._tapZoom.disable();
48
- }
49
-
50
- /**
51
- * Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
52
- *
53
- * @returns `true` if the "double click to zoom" interaction is enabled.
54
- */
55
- isEnabled() {
56
- return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();
57
- }
58
-
59
- /**
60
- * Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
61
- *
62
- * @returns `true` if the "double click to zoom" interaction is active.
63
- */
64
- isActive() {
65
- return this._clickZoom.isActive() || this._tapZoom.isActive();
66
- }
67
- }
68
- exports.DoubleClickZoomHandler = DoubleClickZoomHandler;