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