@antv/l7-map 2.21.11-beta.5 → 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,62 +1,54 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
// tslint:disable-next-line:no-submodule-imports
|
|
6
|
-
import { lodashUtil } from '@antv/l7-utils';
|
|
7
|
-
import { bezier, clamp, now } from "../util";
|
|
8
|
-
const {
|
|
9
|
-
merge
|
|
10
|
-
} = lodashUtil;
|
|
2
|
+
import Point from '@mapbox/point-geometry';
|
|
3
|
+
import { browser } from "./util/browser";
|
|
4
|
+
import { bezier, clamp, extend } from "./util/util";
|
|
11
5
|
const defaultInertiaOptions = {
|
|
12
6
|
linearity: 0.3,
|
|
13
7
|
easing: bezier(0, 0, 0.3, 1)
|
|
14
8
|
};
|
|
15
|
-
const defaultPanInertiaOptions =
|
|
9
|
+
const defaultPanInertiaOptions = extend({
|
|
16
10
|
deceleration: 2500,
|
|
17
11
|
maxSpeed: 1400
|
|
18
12
|
}, defaultInertiaOptions);
|
|
19
|
-
const defaultZoomInertiaOptions =
|
|
13
|
+
const defaultZoomInertiaOptions = extend({
|
|
20
14
|
deceleration: 20,
|
|
21
15
|
maxSpeed: 1400
|
|
22
16
|
}, defaultInertiaOptions);
|
|
23
|
-
const defaultBearingInertiaOptions =
|
|
17
|
+
const defaultBearingInertiaOptions = extend({
|
|
24
18
|
deceleration: 1000,
|
|
25
19
|
maxSpeed: 360
|
|
26
20
|
}, defaultInertiaOptions);
|
|
27
|
-
const defaultPitchInertiaOptions =
|
|
21
|
+
const defaultPitchInertiaOptions = extend({
|
|
28
22
|
deceleration: 1000,
|
|
29
23
|
maxSpeed: 90
|
|
30
24
|
}, defaultInertiaOptions);
|
|
31
|
-
export
|
|
25
|
+
export class HandlerInertia {
|
|
32
26
|
constructor(map) {
|
|
33
|
-
_defineProperty(this, "
|
|
34
|
-
_defineProperty(this, "
|
|
35
|
-
this.
|
|
27
|
+
_defineProperty(this, "_map", void 0);
|
|
28
|
+
_defineProperty(this, "_inertiaBuffer", void 0);
|
|
29
|
+
this._map = map;
|
|
36
30
|
this.clear();
|
|
37
31
|
}
|
|
38
32
|
clear() {
|
|
39
|
-
this.
|
|
33
|
+
this._inertiaBuffer = [];
|
|
40
34
|
}
|
|
41
35
|
record(settings) {
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
time: now(),
|
|
36
|
+
this._drainInertiaBuffer();
|
|
37
|
+
this._inertiaBuffer.push({
|
|
38
|
+
time: browser.now(),
|
|
45
39
|
settings
|
|
46
40
|
});
|
|
47
41
|
}
|
|
48
|
-
|
|
49
|
-
const inertia = this.
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
_drainInertiaBuffer() {
|
|
43
|
+
const inertia = this._inertiaBuffer,
|
|
44
|
+
now = browser.now(),
|
|
45
|
+
cutoff = 160; //msec
|
|
52
46
|
|
|
53
|
-
while (inertia.length > 0 &&
|
|
54
|
-
inertia.shift();
|
|
55
|
-
}
|
|
47
|
+
while (inertia.length > 0 && now - inertia[0].time > cutoff) inertia.shift();
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
if (this.
|
|
49
|
+
_onMoveEnd(panInertiaOptions) {
|
|
50
|
+
this._drainInertiaBuffer();
|
|
51
|
+
if (this._inertiaBuffer.length < 2) {
|
|
60
52
|
return;
|
|
61
53
|
}
|
|
62
54
|
const deltas = {
|
|
@@ -69,50 +61,44 @@ export default class HandlerInertia {
|
|
|
69
61
|
};
|
|
70
62
|
for (const {
|
|
71
63
|
settings
|
|
72
|
-
} of this.
|
|
64
|
+
} of this._inertiaBuffer) {
|
|
73
65
|
deltas.zoom += settings.zoomDelta || 0;
|
|
74
66
|
deltas.bearing += settings.bearingDelta || 0;
|
|
75
67
|
deltas.pitch += settings.pitchDelta || 0;
|
|
76
|
-
if (settings.panDelta)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (settings.around) {
|
|
80
|
-
deltas.around = settings.around;
|
|
81
|
-
}
|
|
82
|
-
if (settings.pinchAround) {
|
|
83
|
-
deltas.pinchAround = settings.pinchAround;
|
|
84
|
-
}
|
|
68
|
+
if (settings.panDelta) deltas.pan._add(settings.panDelta);
|
|
69
|
+
if (settings.around) deltas.around = settings.around;
|
|
70
|
+
if (settings.pinchAround) deltas.pinchAround = settings.pinchAround;
|
|
85
71
|
}
|
|
86
|
-
const lastEntry = this.
|
|
87
|
-
const duration = lastEntry.time - this.
|
|
72
|
+
const lastEntry = this._inertiaBuffer[this._inertiaBuffer.length - 1];
|
|
73
|
+
const duration = lastEntry.time - this._inertiaBuffer[0].time;
|
|
88
74
|
const easeOptions = {};
|
|
89
75
|
if (deltas.pan.mag()) {
|
|
90
|
-
const result = calculateEasing(deltas.pan.mag(), duration,
|
|
76
|
+
const result = calculateEasing(deltas.pan.mag(), duration, extend({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
91
77
|
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
92
|
-
easeOptions.center = this.
|
|
78
|
+
easeOptions.center = this._map.transform.center;
|
|
93
79
|
extendDuration(easeOptions, result);
|
|
94
80
|
}
|
|
95
81
|
if (deltas.zoom) {
|
|
96
82
|
const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
97
|
-
easeOptions.zoom = this.
|
|
83
|
+
easeOptions.zoom = this._map.transform.zoom + result.amount;
|
|
98
84
|
extendDuration(easeOptions, result);
|
|
99
85
|
}
|
|
100
86
|
if (deltas.bearing) {
|
|
101
87
|
const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
102
|
-
easeOptions.bearing = this.
|
|
88
|
+
easeOptions.bearing = this._map.transform.bearing + clamp(result.amount, -179, 179);
|
|
103
89
|
extendDuration(easeOptions, result);
|
|
104
90
|
}
|
|
105
91
|
if (deltas.pitch) {
|
|
106
92
|
const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
107
|
-
easeOptions.pitch = this.
|
|
93
|
+
easeOptions.pitch = this._map.transform.pitch + result.amount;
|
|
108
94
|
extendDuration(easeOptions, result);
|
|
109
95
|
}
|
|
110
96
|
if (easeOptions.zoom || easeOptions.bearing) {
|
|
111
97
|
const last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
112
|
-
easeOptions.around = last ? this.
|
|
98
|
+
easeOptions.around = last ? this._map.unproject(last) : this._map.getCenter();
|
|
113
99
|
}
|
|
114
100
|
this.clear();
|
|
115
|
-
return
|
|
101
|
+
return extend(easeOptions, {
|
|
116
102
|
noMoveStart: true
|
|
117
103
|
});
|
|
118
104
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/// <reference types="mapbox__point-geometry" />
|
|
2
|
+
import Point from '@mapbox/point-geometry';
|
|
3
|
+
import { HandlerInertia } from './handler_inertia';
|
|
4
|
+
import type { CompleteMapOptions, Map } from './map';
|
|
5
|
+
import { Event } from './util/evented';
|
|
6
|
+
/**
|
|
7
|
+
* Handlers interpret dom events and return camera changes that should be
|
|
8
|
+
* applied to the map (`HandlerResult`s). The camera changes are all deltas.
|
|
9
|
+
* The handler itself should have no knowledge of the map's current state.
|
|
10
|
+
* This makes it easier to merge multiple results and keeps handlers simpler.
|
|
11
|
+
* For example, if there is a mousedown and mousemove, the mousePan handler
|
|
12
|
+
* would return a `panDelta` on the mousemove.
|
|
13
|
+
*/
|
|
14
|
+
export interface Handler {
|
|
15
|
+
enable(): void;
|
|
16
|
+
disable(): void;
|
|
17
|
+
isEnabled(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* This is used to indicate if the handler is currently active or not.
|
|
20
|
+
* In case a handler is active, it will block other handlers from getting the relevant events.
|
|
21
|
+
* There is an allow list of handlers that can be active at the same time, which is configured when adding a handler.
|
|
22
|
+
*/
|
|
23
|
+
isActive(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `reset` can be called by the manager at any time and must reset everything to it's original state
|
|
26
|
+
*/
|
|
27
|
+
reset(): void;
|
|
28
|
+
readonly touchstart?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
29
|
+
readonly touchmove?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
30
|
+
readonly touchmoveWindow?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
31
|
+
readonly touchend?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
32
|
+
readonly touchcancel?: (e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>) => HandlerResult | void;
|
|
33
|
+
readonly mousedown?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
34
|
+
readonly mousemove?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
35
|
+
readonly mousemoveWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
36
|
+
readonly mouseup?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
37
|
+
readonly mouseupWindow?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
38
|
+
readonly dblclick?: (e: MouseEvent, point: Point) => HandlerResult | void;
|
|
39
|
+
readonly contextmenu?: (e: MouseEvent) => HandlerResult | void;
|
|
40
|
+
readonly wheel?: (e: WheelEvent, point: Point) => HandlerResult | void;
|
|
41
|
+
readonly keydown?: (e: KeyboardEvent) => HandlerResult | void;
|
|
42
|
+
readonly keyup?: (e: KeyboardEvent) => HandlerResult | void;
|
|
43
|
+
/**
|
|
44
|
+
* `renderFrame` is the only non-dom event. It is called during render
|
|
45
|
+
* frames and can be used to smooth camera changes (see scroll handler).
|
|
46
|
+
*/
|
|
47
|
+
readonly renderFrame?: () => HandlerResult | void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* All handler methods that are called with events can optionally return a `HandlerResult`.
|
|
51
|
+
*/
|
|
52
|
+
export type HandlerResult = {
|
|
53
|
+
panDelta?: Point;
|
|
54
|
+
zoomDelta?: number;
|
|
55
|
+
bearingDelta?: number;
|
|
56
|
+
pitchDelta?: number;
|
|
57
|
+
/**
|
|
58
|
+
* the point to not move when changing the camera
|
|
59
|
+
*/
|
|
60
|
+
around?: Point | null;
|
|
61
|
+
/**
|
|
62
|
+
* same as above, except for pinch actions, which are given higher priority
|
|
63
|
+
*/
|
|
64
|
+
pinchAround?: Point | null;
|
|
65
|
+
/**
|
|
66
|
+
* A method that can fire a one-off easing by directly changing the map's camera.
|
|
67
|
+
*/
|
|
68
|
+
cameraAnimation?: (map: Map) => any;
|
|
69
|
+
/**
|
|
70
|
+
* The last three properties are needed by only one handler: scrollzoom.
|
|
71
|
+
* The DOM event to be used as the `originalEvent` on any camera change events.
|
|
72
|
+
*/
|
|
73
|
+
originalEvent?: Event;
|
|
74
|
+
/**
|
|
75
|
+
* Makes the manager trigger a frame, allowing the handler to return multiple results over time (see scrollzoom).
|
|
76
|
+
*/
|
|
77
|
+
needsRenderFrame?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The camera changes won't get recorded for inertial zooming.
|
|
80
|
+
*/
|
|
81
|
+
noInertia?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type EventInProgress = {
|
|
84
|
+
handlerName: string;
|
|
85
|
+
originalEvent: Event;
|
|
86
|
+
};
|
|
87
|
+
export type EventsInProgress = {
|
|
88
|
+
zoom?: EventInProgress;
|
|
89
|
+
pitch?: EventInProgress;
|
|
90
|
+
rotate?: EventInProgress;
|
|
91
|
+
drag?: EventInProgress;
|
|
92
|
+
};
|
|
93
|
+
export declare class HandlerManager {
|
|
94
|
+
_map: Map;
|
|
95
|
+
_el: HTMLElement;
|
|
96
|
+
_handlers: Array<{
|
|
97
|
+
handlerName: string;
|
|
98
|
+
handler: Handler;
|
|
99
|
+
allowed: Array<string>;
|
|
100
|
+
}>;
|
|
101
|
+
_eventsInProgress: EventsInProgress;
|
|
102
|
+
_frameId: number;
|
|
103
|
+
_inertia: HandlerInertia;
|
|
104
|
+
_bearingSnap: number;
|
|
105
|
+
_handlersById: {
|
|
106
|
+
[x: string]: Handler;
|
|
107
|
+
};
|
|
108
|
+
_updatingCamera: boolean;
|
|
109
|
+
_changes: Array<[HandlerResult, EventsInProgress, {
|
|
110
|
+
[handlerName: string]: Event;
|
|
111
|
+
}]>;
|
|
112
|
+
_zoom: {
|
|
113
|
+
handlerName: string;
|
|
114
|
+
};
|
|
115
|
+
_previousActiveHandlers: {
|
|
116
|
+
[x: string]: Handler;
|
|
117
|
+
};
|
|
118
|
+
_listeners: Array<[
|
|
119
|
+
Window | Document | HTMLElement,
|
|
120
|
+
string,
|
|
121
|
+
({
|
|
122
|
+
passive?: boolean;
|
|
123
|
+
capture?: boolean;
|
|
124
|
+
} | undefined)
|
|
125
|
+
]>;
|
|
126
|
+
constructor(map: Map, options: CompleteMapOptions);
|
|
127
|
+
destroy(): void;
|
|
128
|
+
_addDefaultHandlers(options: CompleteMapOptions): void;
|
|
129
|
+
_add(handlerName: string, handler: Handler, allowed?: Array<string>): void;
|
|
130
|
+
stop(allowEndAnimation: boolean): void;
|
|
131
|
+
isActive(): boolean;
|
|
132
|
+
isZooming(): boolean;
|
|
133
|
+
isRotating(): boolean;
|
|
134
|
+
isMoving(): boolean;
|
|
135
|
+
_blockedByActive(activeHandlers: {
|
|
136
|
+
[x: string]: Handler;
|
|
137
|
+
}, allowed: Array<string>, myName: string): boolean;
|
|
138
|
+
handleWindowEvent: (e: {
|
|
139
|
+
type: 'mousemove' | 'mouseup' | 'touchmove';
|
|
140
|
+
}) => void;
|
|
141
|
+
_getMapTouches(touches: TouchList): TouchList;
|
|
142
|
+
handleEvent: (e: Event, eventName?: keyof Handler) => void;
|
|
143
|
+
mergeHandlerResult(mergedHandlerResult: HandlerResult, eventsInProgress: EventsInProgress, handlerResult: HandlerResult, name: string, e?: UIEvent): void;
|
|
144
|
+
_applyChanges(): void;
|
|
145
|
+
_updateMapTransform(combinedResult: HandlerResult, combinedEventsInProgress: EventsInProgress, deactivatedHandlers: {
|
|
146
|
+
[handlerName: string]: Event;
|
|
147
|
+
}): void;
|
|
148
|
+
_fireEvents(newEventsInProgress: EventsInProgress, deactivatedHandlers: {
|
|
149
|
+
[handlerName: string]: Event;
|
|
150
|
+
}, allowEndAnimation: boolean): void;
|
|
151
|
+
_fireEvent(type: string, e?: Event): void;
|
|
152
|
+
_requestFrame(): number;
|
|
153
|
+
_triggerRenderFrame(): void;
|
|
154
|
+
}
|