maplibre-gl 3.1.0 → 3.2.0-pre.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-struct-arrays.ts +9 -12
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3303 -3398
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3899 -3531
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +28 -25
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +36 -26
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +61 -44
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +34 -27
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +12 -11
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/value.ts +1 -1
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +8 -14
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +12 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +85 -65
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +18 -16
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +5 -4
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +7 -1
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/shaders.ts +1 -3
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +75 -59
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +23 -10
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +17 -38
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +34 -24
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +11 -23
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +21 -28
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +39 -33
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +23 -48
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +392 -361
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +21 -26
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +181 -194
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +46 -42
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +14 -18
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +570 -1281
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +97 -8
- package/src/ui/map.ts +856 -702
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +220 -141
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +179 -147
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +2 -6
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +6 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +6 -0
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +2 -4
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
2
2
|
|
|
3
3
|
import {Event} from '../../util/evented';
|
|
4
|
-
import TransformProvider from './transform-provider';
|
|
4
|
+
import {TransformProvider} from './transform-provider';
|
|
5
5
|
|
|
6
|
-
import type Map from '../map';
|
|
6
|
+
import type {Map} from '../map';
|
|
7
7
|
import type Point from '@mapbox/point-geometry';
|
|
8
|
+
import {Handler} from '../handler_manager';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
11
12
|
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
13
|
+
*
|
|
14
|
+
* @group Handlers
|
|
12
15
|
*/
|
|
13
|
-
class BoxZoomHandler {
|
|
16
|
+
export class BoxZoomHandler implements Handler {
|
|
14
17
|
_map: Map;
|
|
15
18
|
_tr: TransformProvider;
|
|
16
19
|
_el: HTMLElement;
|
|
@@ -23,7 +26,7 @@ class BoxZoomHandler {
|
|
|
23
26
|
_clickTolerance: number;
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
|
-
* @
|
|
29
|
+
* @hidden
|
|
27
30
|
*/
|
|
28
31
|
constructor(map: Map, options: {
|
|
29
32
|
clickTolerance: number;
|
|
@@ -38,7 +41,7 @@ class BoxZoomHandler {
|
|
|
38
41
|
/**
|
|
39
42
|
* Returns a Boolean indicating whether the "box zoom" interaction is enabled.
|
|
40
43
|
*
|
|
41
|
-
* @returns
|
|
44
|
+
* @returns `true` if the "box zoom" interaction is enabled.
|
|
42
45
|
*/
|
|
43
46
|
isEnabled() {
|
|
44
47
|
return !!this._enabled;
|
|
@@ -47,7 +50,7 @@ class BoxZoomHandler {
|
|
|
47
50
|
/**
|
|
48
51
|
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
49
52
|
*
|
|
50
|
-
* @returns
|
|
53
|
+
* @returns `true` if the "box zoom" interaction is active.
|
|
51
54
|
*/
|
|
52
55
|
isActive() {
|
|
53
56
|
return !!this._active;
|
|
@@ -57,7 +60,9 @@ class BoxZoomHandler {
|
|
|
57
60
|
* Enables the "box zoom" interaction.
|
|
58
61
|
*
|
|
59
62
|
* @example
|
|
60
|
-
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* map.boxZoom.enable();
|
|
65
|
+
* ```
|
|
61
66
|
*/
|
|
62
67
|
enable() {
|
|
63
68
|
if (this.isEnabled()) return;
|
|
@@ -68,7 +73,9 @@ class BoxZoomHandler {
|
|
|
68
73
|
* Disables the "box zoom" interaction.
|
|
69
74
|
*
|
|
70
75
|
* @example
|
|
71
|
-
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* map.boxZoom.disable();
|
|
78
|
+
* ```
|
|
72
79
|
*/
|
|
73
80
|
disable() {
|
|
74
81
|
if (!this.isEnabled()) return;
|
|
@@ -164,5 +171,3 @@ class BoxZoomHandler {
|
|
|
164
171
|
return this._map.fire(new Event(type, {originalEvent: e}));
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
|
-
|
|
168
|
-
export default BoxZoomHandler;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type Point from '@mapbox/point-geometry';
|
|
2
|
-
import type Map from '../map';
|
|
3
|
-
import TransformProvider from './transform-provider';
|
|
2
|
+
import type {Map} from '../map';
|
|
3
|
+
import {TransformProvider} from './transform-provider';
|
|
4
|
+
import {Handler} from '../handler_manager';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking
|
|
8
|
+
* It is used by other handlers
|
|
9
|
+
*/
|
|
10
|
+
export class ClickZoomHandler implements Handler {
|
|
6
11
|
|
|
7
12
|
_tr: TransformProvider;
|
|
8
13
|
_enabled: boolean;
|
|
9
14
|
_active: boolean;
|
|
10
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
11
19
|
constructor(map: Map) {
|
|
12
20
|
this._tr = new TransformProvider(map);
|
|
13
21
|
this.reset();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import browser from '../../util/browser';
|
|
2
|
-
import Map from '../map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {browser} from '../../util/browser';
|
|
2
|
+
import {Map} from '../map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
5
|
import {beforeMapTest} from '../../util/test/util';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
2
2
|
import {beforeMapTest} from '../../util/test/util';
|
|
3
|
-
import Map,
|
|
3
|
+
import {Map, MapOptions} from '../map';
|
|
4
4
|
|
|
5
5
|
function createMap() {
|
|
6
6
|
return new Map({container: window.document.createElement('div')} as any as MapOptions);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
2
2
|
import type Point from '@mapbox/point-geometry';
|
|
3
3
|
import {DragMoveStateManager} from './drag_move_state_manager';
|
|
4
4
|
import {Handler} from '../handler_manager';
|
|
@@ -26,27 +26,42 @@ export interface DragPitchResult extends DragMovementResult {
|
|
|
26
26
|
type DragMoveFunction<T extends DragMovementResult> = (lastPoint: Point, point: Point) => T;
|
|
27
27
|
|
|
28
28
|
export interface DragMoveHandler<T extends DragMovementResult, E extends Event> extends Handler {
|
|
29
|
-
reset: (e?: E) => void;
|
|
30
29
|
dragStart: (e: E, point: Point) => void;
|
|
31
30
|
dragMove: (e: E, point: Point) => T | void;
|
|
32
31
|
dragEnd: (e: E) => void;
|
|
33
|
-
enable: () => void;
|
|
34
|
-
disable: () => void;
|
|
35
|
-
isEnabled: () => boolean;
|
|
36
|
-
isActive: () => boolean;
|
|
37
32
|
getClickTolerance: () => number;
|
|
38
33
|
}
|
|
39
34
|
|
|
35
|
+
export type DragMoveHandlerOptions<T, E extends Event> = {
|
|
36
|
+
/**
|
|
37
|
+
* If the movement is shorter than this value, consider it a click.
|
|
38
|
+
*/
|
|
39
|
+
clickTolerance: number;
|
|
40
|
+
/**
|
|
41
|
+
* The move function to run on a valid movement.
|
|
42
|
+
*/
|
|
43
|
+
move: DragMoveFunction<T>;
|
|
44
|
+
/**
|
|
45
|
+
* A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.
|
|
46
|
+
*/
|
|
47
|
+
moveStateManager: DragMoveStateManager<E>;
|
|
48
|
+
/**
|
|
49
|
+
* A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler
|
|
50
|
+
* @param handler - the handler
|
|
51
|
+
*/
|
|
52
|
+
assignEvents: (handler: DragMoveHandler<T, E>) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Should the move start on the "start" event, or should it start on the first valid move.
|
|
55
|
+
*/
|
|
56
|
+
activateOnStart?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* If true, handler will be enabled during construction
|
|
59
|
+
*/
|
|
60
|
+
enable?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
40
63
|
/**
|
|
41
64
|
* A generic class to create handlers for drag events, from both mouse and touch events.
|
|
42
|
-
* @implements {DragMoveHandler<T, E>}
|
|
43
|
-
* @param {Object} options
|
|
44
|
-
* @param {number} options.clickTolerance If the movement is shorter than this value, consider it a click.
|
|
45
|
-
* @param {string} options.move The move function to run on a valid movement.
|
|
46
|
-
* @param {DragMoveStateManager<E>} options.moveStateManager A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.
|
|
47
|
-
* @param {function} options.assignEvent A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler
|
|
48
|
-
* @param {boolean} [options.activateOnStart] Should the move start on the "start" event, or should it start on the first valid move.
|
|
49
|
-
* @param {boolean} [options.enable] If true, handler will be enabled during construction
|
|
50
65
|
*/
|
|
51
66
|
export class DragHandler<T extends DragMovementResult, E extends Event> implements DragMoveHandler<T, E> {
|
|
52
67
|
// Event handlers that may be assigned by the implementations of this class
|
|
@@ -67,14 +82,7 @@ export class DragHandler<T extends DragMovementResult, E extends Event> implemen
|
|
|
67
82
|
_lastPoint: Point | null;
|
|
68
83
|
_moveStateManager: DragMoveStateManager<E>;
|
|
69
84
|
|
|
70
|
-
constructor(options: {
|
|
71
|
-
clickTolerance: number;
|
|
72
|
-
move: DragMoveFunction<T>;
|
|
73
|
-
moveStateManager: DragMoveStateManager<E>;
|
|
74
|
-
assignEvents: (handler: DragMoveHandler<T, E>) => void;
|
|
75
|
-
activateOnStart?: boolean;
|
|
76
|
-
enable?: boolean;
|
|
77
|
-
}) {
|
|
85
|
+
constructor(options: DragMoveHandlerOptions<T, E>) {
|
|
78
86
|
this._enabled = !!options.enable;
|
|
79
87
|
this._moveStateManager = options.moveStateManager;
|
|
80
88
|
this._clickTolerance = options.clickTolerance || 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
2
2
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
3
3
|
import {beforeMapTest} from '../../util/test/util';
|
|
4
|
-
import Map,
|
|
4
|
+
import {Map, MapOptions} from '../map';
|
|
5
5
|
import type {MapGeoJSONFeature} from '../../util/vectortile_to_geojson';
|
|
6
6
|
|
|
7
7
|
function createMap(clickTolerance?, dragPan?) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {extend} from '../../util/util';
|
|
2
|
-
import Map from '../map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
2
|
+
import {Map} from '../map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
|
-
import browser from '../../util/browser';
|
|
5
|
+
import {browser} from '../../util/browser';
|
|
6
6
|
|
|
7
7
|
import {beforeMapTest} from '../../util/test/util';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Map from '../../ui/map';
|
|
2
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {Map} from '../../ui/map';
|
|
2
|
+
import {DOM} from '../../util/dom';
|
|
3
3
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
4
4
|
import {extend} from '../../util/util';
|
|
5
5
|
import {beforeMapTest} from '../../util/test/util';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import {Handler} from '../handler_manager';
|
|
2
|
+
import type {Map} from '../map';
|
|
3
|
+
import {TransformProvider} from './transform-provider';
|
|
3
4
|
|
|
4
5
|
const defaultOptions = {
|
|
5
6
|
panStep: 100,
|
|
@@ -20,8 +21,10 @@ const defaultOptions = {
|
|
|
20
21
|
* - `Shift+⇠`: Decrease the rotation by 15 degrees.
|
|
21
22
|
* - `Shift+⇡`: Increase the pitch by 10 degrees.
|
|
22
23
|
* - `Shift+⇣`: Decrease the pitch by 10 degrees.
|
|
24
|
+
*
|
|
25
|
+
* @group Handlers
|
|
23
26
|
*/
|
|
24
|
-
class KeyboardHandler {
|
|
27
|
+
export class KeyboardHandler implements Handler {
|
|
25
28
|
_tr: TransformProvider;
|
|
26
29
|
_enabled: boolean;
|
|
27
30
|
_active: boolean;
|
|
@@ -31,7 +34,7 @@ class KeyboardHandler {
|
|
|
31
34
|
_rotationDisabled: boolean;
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
|
-
* @
|
|
37
|
+
* @hidden
|
|
35
38
|
*/
|
|
36
39
|
constructor(map: Map) {
|
|
37
40
|
this._tr = new TransformProvider(map);
|
|
@@ -136,7 +139,9 @@ class KeyboardHandler {
|
|
|
136
139
|
* Enables the "keyboard rotate and zoom" interaction.
|
|
137
140
|
*
|
|
138
141
|
* @example
|
|
139
|
-
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* map.keyboard.enable();
|
|
144
|
+
* ```
|
|
140
145
|
*/
|
|
141
146
|
enable() {
|
|
142
147
|
this._enabled = true;
|
|
@@ -146,7 +151,9 @@ class KeyboardHandler {
|
|
|
146
151
|
* Disables the "keyboard rotate and zoom" interaction.
|
|
147
152
|
*
|
|
148
153
|
* @example
|
|
149
|
-
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* map.keyboard.disable();
|
|
156
|
+
* ```
|
|
150
157
|
*/
|
|
151
158
|
disable() {
|
|
152
159
|
this._enabled = false;
|
|
@@ -157,7 +164,7 @@ class KeyboardHandler {
|
|
|
157
164
|
* Returns a Boolean indicating whether the "keyboard rotate and zoom"
|
|
158
165
|
* interaction is enabled.
|
|
159
166
|
*
|
|
160
|
-
* @returns
|
|
167
|
+
* @returns `true` if the "keyboard rotate and zoom"
|
|
161
168
|
* interaction is enabled.
|
|
162
169
|
*/
|
|
163
170
|
isEnabled() {
|
|
@@ -168,7 +175,7 @@ class KeyboardHandler {
|
|
|
168
175
|
* Returns true if the handler is enabled and has detected the start of a
|
|
169
176
|
* zoom/rotate gesture.
|
|
170
177
|
*
|
|
171
|
-
* @returns
|
|
178
|
+
* @returns `true` if the handler is enabled and has detected the
|
|
172
179
|
* start of a zoom/rotate gesture.
|
|
173
180
|
*/
|
|
174
181
|
isActive() {
|
|
@@ -180,7 +187,9 @@ class KeyboardHandler {
|
|
|
180
187
|
* "keyboard zoom" interaction enabled.
|
|
181
188
|
*
|
|
182
189
|
* @example
|
|
183
|
-
*
|
|
190
|
+
* ```ts
|
|
191
|
+
* map.keyboard.disableRotation();
|
|
192
|
+
* ```
|
|
184
193
|
*/
|
|
185
194
|
disableRotation() {
|
|
186
195
|
this._rotationDisabled = true;
|
|
@@ -190,8 +199,10 @@ class KeyboardHandler {
|
|
|
190
199
|
* Enables the "keyboard pan/rotate" interaction.
|
|
191
200
|
*
|
|
192
201
|
* @example
|
|
193
|
-
*
|
|
194
|
-
*
|
|
202
|
+
* ```ts
|
|
203
|
+
* map.keyboard.enable();
|
|
204
|
+
* map.keyboard.enableRotation();
|
|
205
|
+
* ```
|
|
195
206
|
*/
|
|
196
207
|
enableRotation() {
|
|
197
208
|
this._rotationDisabled = false;
|
|
@@ -201,5 +212,3 @@ class KeyboardHandler {
|
|
|
201
212
|
function easeOut(t: number) {
|
|
202
213
|
return t * (2 - t);
|
|
203
214
|
}
|
|
204
|
-
|
|
205
|
-
export default KeyboardHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Map,
|
|
2
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {Map, MapOptions} from '../map';
|
|
2
|
+
import {DOM} from '../../util/dom';
|
|
3
3
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
4
4
|
import {beforeMapTest} from '../../util/test/util';
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {MapMouseEvent, MapTouchEvent, MapWheelEvent} from '../events';
|
|
2
2
|
import {Handler} from '../handler_manager';
|
|
3
|
-
import type Map from '../map';
|
|
3
|
+
import type {Map} from '../map';
|
|
4
4
|
import type Point from '@mapbox/point-geometry';
|
|
5
5
|
|
|
6
6
|
export class MapEventHandler implements Handler {
|
package/src/ui/handler/mouse.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Point from '@mapbox/point-geometry';
|
|
2
2
|
|
|
3
|
-
import DOM from '../../util/dom';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import {DragMoveHandler, DragPanResult, DragRotateResult, DragPitchResult, DragHandler} from './drag_handler';
|
|
5
5
|
import {MouseMoveStateManager} from './drag_move_state_manager';
|
|
6
6
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {extend} from '../../util/util';
|
|
2
|
-
import Map from '../../ui/map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
2
|
+
import {Map} from '../../ui/map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
|
-
import browser from '../../util/browser';
|
|
5
|
+
import {browser} from '../../util/browser';
|
|
6
6
|
import {beforeMapTest} from '../../util/test/util';
|
|
7
7
|
|
|
8
8
|
function createMap(options?) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import browser from '../../util/browser';
|
|
2
|
-
import Map from '../../ui/map';
|
|
3
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {browser} from '../../util/browser';
|
|
2
|
+
import {Map} from '../../ui/map';
|
|
3
|
+
import {DOM} from '../../util/dom';
|
|
4
4
|
import simulate from '../../../test/unit/lib/simulate_interaction';
|
|
5
5
|
import {setPerformance, beforeMapTest} from '../../util/test/util';
|
|
6
6
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import DOM from '../../util/dom';
|
|
1
|
+
import {DOM} from '../../util/dom';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import browser from '../../util/browser';
|
|
3
|
+
import {defaultEasing, bezier} from '../../util/util';
|
|
4
|
+
import {browser} from '../../util/browser';
|
|
5
5
|
import {interpolates} from '@maplibre/maplibre-gl-style-spec';
|
|
6
|
-
import LngLat from '../../geo/lng_lat';
|
|
7
|
-
import TransformProvider from './transform-provider';
|
|
6
|
+
import {LngLat} from '../../geo/lng_lat';
|
|
7
|
+
import {TransformProvider} from './transform-provider';
|
|
8
8
|
|
|
9
|
-
import type Map from '../map';
|
|
10
|
-
import type HandlerManager from '../handler_manager';
|
|
9
|
+
import type {Map} from '../map';
|
|
11
10
|
import type Point from '@mapbox/point-geometry';
|
|
11
|
+
import type {AroundCenterOptions} from './two_fingers_touch';
|
|
12
|
+
import {Handler} from '../handler_manager';
|
|
12
13
|
|
|
13
14
|
// deltaY value for mouse scroll wheel identification
|
|
14
15
|
const wheelZoomDelta = 4.000244140625;
|
|
@@ -22,20 +23,12 @@ const wheelZoomRate = 1 / 450;
|
|
|
22
23
|
// is used to limit zoom rate in the case of very fast scrolling
|
|
23
24
|
const maxScalePerFrame = 2;
|
|
24
25
|
|
|
25
|
-
/**
|
|
26
|
-
* The scroll zoom handler options object
|
|
27
|
-
*/
|
|
28
|
-
export type ScrollZoomHandlerOptions = {
|
|
29
|
-
/**
|
|
30
|
-
* If "center" is passed, map will zoom around the center of map
|
|
31
|
-
*/
|
|
32
|
-
around?: 'center';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
26
|
/**
|
|
36
27
|
* The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
|
|
28
|
+
*
|
|
29
|
+
* @group Handlers
|
|
37
30
|
*/
|
|
38
|
-
class ScrollZoomHandler {
|
|
31
|
+
export class ScrollZoomHandler implements Handler {
|
|
39
32
|
_map: Map;
|
|
40
33
|
_tr: TransformProvider;
|
|
41
34
|
_el: HTMLElement;
|
|
@@ -64,34 +57,34 @@ class ScrollZoomHandler {
|
|
|
64
57
|
};
|
|
65
58
|
|
|
66
59
|
_frameId: boolean;
|
|
67
|
-
|
|
60
|
+
_triggerRenderFrame: () => void;
|
|
68
61
|
|
|
69
62
|
_defaultZoomRate: number;
|
|
70
63
|
_wheelZoomRate: number;
|
|
71
64
|
|
|
72
65
|
/**
|
|
73
|
-
* @
|
|
66
|
+
* @hidden
|
|
74
67
|
*/
|
|
75
|
-
constructor(map: Map,
|
|
68
|
+
constructor(map: Map, triggerRenderFrame: () => void) {
|
|
76
69
|
this._map = map;
|
|
77
70
|
this._tr = new TransformProvider(map);
|
|
78
71
|
this._el = map.getCanvasContainer();
|
|
79
|
-
this.
|
|
72
|
+
this._triggerRenderFrame = triggerRenderFrame;
|
|
80
73
|
|
|
81
74
|
this._delta = 0;
|
|
82
75
|
|
|
83
76
|
this._defaultZoomRate = defaultZoomRate;
|
|
84
77
|
this._wheelZoomRate = wheelZoomRate;
|
|
85
|
-
|
|
86
|
-
bindAll(['_onTimeout'], this);
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
/**
|
|
90
81
|
* Set the zoom rate of a trackpad
|
|
91
|
-
* @param
|
|
82
|
+
* @param zoomRate - 1/100 The rate used to scale trackpad movement to a zoom value.
|
|
92
83
|
* @example
|
|
93
|
-
*
|
|
84
|
+
* Speed up trackpad zoom
|
|
85
|
+
* ```ts
|
|
94
86
|
* map.scrollZoom.setZoomRate(1/25);
|
|
87
|
+
* ```
|
|
95
88
|
*/
|
|
96
89
|
setZoomRate(zoomRate: number) {
|
|
97
90
|
this._defaultZoomRate = zoomRate;
|
|
@@ -99,10 +92,12 @@ class ScrollZoomHandler {
|
|
|
99
92
|
|
|
100
93
|
/**
|
|
101
94
|
* Set the zoom rate of a mouse wheel
|
|
102
|
-
* @param
|
|
95
|
+
* @param wheelZoomRate - 1/450 The rate used to scale mouse wheel movement to a zoom value.
|
|
103
96
|
* @example
|
|
104
|
-
*
|
|
97
|
+
* Slow down zoom of mouse wheel
|
|
98
|
+
* ```ts
|
|
105
99
|
* map.scrollZoom.setWheelZoomRate(1/600);
|
|
100
|
+
* ```
|
|
106
101
|
*/
|
|
107
102
|
setWheelZoomRate(wheelZoomRate: number) {
|
|
108
103
|
this._wheelZoomRate = wheelZoomRate;
|
|
@@ -110,8 +105,7 @@ class ScrollZoomHandler {
|
|
|
110
105
|
|
|
111
106
|
/**
|
|
112
107
|
* Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
|
|
113
|
-
*
|
|
114
|
-
* @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
|
|
108
|
+
* @returns `true` if the "scroll to zoom" interaction is enabled.
|
|
115
109
|
*/
|
|
116
110
|
isEnabled() {
|
|
117
111
|
return !!this._enabled;
|
|
@@ -133,25 +127,26 @@ class ScrollZoomHandler {
|
|
|
133
127
|
/**
|
|
134
128
|
* Enables the "scroll to zoom" interaction.
|
|
135
129
|
*
|
|
136
|
-
* @param
|
|
137
|
-
* @param {string} [options.around] If "center" is passed, map will zoom around the center of map
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* map.scrollZoom.enable();
|
|
130
|
+
* @param options - Options object.
|
|
141
131
|
* @example
|
|
142
|
-
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* map.scrollZoom.enable();
|
|
134
|
+
* map.scrollZoom.enable({ around: 'center' })
|
|
135
|
+
* ```
|
|
143
136
|
*/
|
|
144
|
-
enable(options?:
|
|
137
|
+
enable(options?: AroundCenterOptions | boolean) {
|
|
145
138
|
if (this.isEnabled()) return;
|
|
146
139
|
this._enabled = true;
|
|
147
|
-
this._aroundCenter = options && options.around === 'center';
|
|
140
|
+
this._aroundCenter = !!options && (options as AroundCenterOptions).around === 'center';
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
/**
|
|
151
144
|
* Disables the "scroll to zoom" interaction.
|
|
152
145
|
*
|
|
153
146
|
* @example
|
|
154
|
-
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* map.scrollZoom.disable();
|
|
149
|
+
* ```
|
|
155
150
|
*/
|
|
156
151
|
disable() {
|
|
157
152
|
if (!this.isEnabled()) return;
|
|
@@ -218,13 +213,13 @@ class ScrollZoomHandler {
|
|
|
218
213
|
e.preventDefault();
|
|
219
214
|
}
|
|
220
215
|
|
|
221
|
-
_onTimeout(initialEvent: MouseEvent) {
|
|
216
|
+
_onTimeout = (initialEvent: MouseEvent) => {
|
|
222
217
|
this._type = 'wheel';
|
|
223
218
|
this._delta -= this._lastValue;
|
|
224
219
|
if (!this._active) {
|
|
225
220
|
this._start(initialEvent);
|
|
226
221
|
}
|
|
227
|
-
}
|
|
222
|
+
};
|
|
228
223
|
|
|
229
224
|
_start(e: MouseEvent) {
|
|
230
225
|
if (!this._delta) return;
|
|
@@ -250,7 +245,7 @@ class ScrollZoomHandler {
|
|
|
250
245
|
this._aroundPoint = tr.transform.locationPoint(this._around);
|
|
251
246
|
if (!this._frameId) {
|
|
252
247
|
this._frameId = true;
|
|
253
|
-
this.
|
|
248
|
+
this._triggerRenderFrame();
|
|
254
249
|
}
|
|
255
250
|
}
|
|
256
251
|
|
|
@@ -317,7 +312,7 @@ class ScrollZoomHandler {
|
|
|
317
312
|
this._active = false;
|
|
318
313
|
this._finishTimeout = setTimeout(() => {
|
|
319
314
|
this._zooming = false;
|
|
320
|
-
this.
|
|
315
|
+
this._triggerRenderFrame();
|
|
321
316
|
delete this._targetZoom;
|
|
322
317
|
delete this._finishTimeout;
|
|
323
318
|
}, 200);
|
|
@@ -333,16 +328,16 @@ class ScrollZoomHandler {
|
|
|
333
328
|
}
|
|
334
329
|
|
|
335
330
|
_smoothOutEasing(duration: number) {
|
|
336
|
-
let easing =
|
|
331
|
+
let easing = defaultEasing;
|
|
337
332
|
|
|
338
333
|
if (this._prevEase) {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
334
|
+
const currentEase = this._prevEase;
|
|
335
|
+
const t = (browser.now() - currentEase.start) / currentEase.duration;
|
|
336
|
+
const speed = currentEase.easing(t + 0.01) - currentEase.easing(t);
|
|
342
337
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
338
|
+
// Quick hack to make new bezier that is continuous with last
|
|
339
|
+
const x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
|
|
340
|
+
const y = Math.sqrt(0.27 * 0.27 - x * x);
|
|
346
341
|
|
|
347
342
|
easing = bezier(x, y, 0.25, 1);
|
|
348
343
|
}
|
|
@@ -360,5 +355,3 @@ class ScrollZoomHandler {
|
|
|
360
355
|
this._active = false;
|
|
361
356
|
}
|
|
362
357
|
}
|
|
363
|
-
|
|
364
|
-
export default ScrollZoomHandler;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import type ClickZoomHandler from '../click_zoom';
|
|
2
|
-
import type TapZoomHandler from './../tap_zoom';
|
|
1
|
+
import type {ClickZoomHandler} from '../click_zoom';
|
|
2
|
+
import type {TapZoomHandler} from './../tap_zoom';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
|
|
6
6
|
* double clicking or double tapping.
|
|
7
|
+
*
|
|
8
|
+
* @group Handlers
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
10
|
+
export class DoubleClickZoomHandler {
|
|
9
11
|
|
|
10
12
|
_clickZoom: ClickZoomHandler;
|
|
11
13
|
_tapZoom: TapZoomHandler;
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
|
-
* @
|
|
16
|
+
* @hidden
|
|
15
17
|
*/
|
|
16
18
|
constructor(clickZoom: ClickZoomHandler, TapZoom: TapZoomHandler) {
|
|
17
19
|
this._clickZoom = clickZoom;
|
|
@@ -22,7 +24,9 @@ export default class DoubleClickZoomHandler {
|
|
|
22
24
|
* Enables the "double click to zoom" interaction.
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
27
|
+
* ```ts
|
|
25
28
|
* map.doubleClickZoom.enable();
|
|
29
|
+
* ```
|
|
26
30
|
*/
|
|
27
31
|
enable() {
|
|
28
32
|
this._clickZoom.enable();
|
|
@@ -33,7 +37,9 @@ export default class DoubleClickZoomHandler {
|
|
|
33
37
|
* Disables the "double click to zoom" interaction.
|
|
34
38
|
*
|
|
35
39
|
* @example
|
|
40
|
+
* ```ts
|
|
36
41
|
* map.doubleClickZoom.disable();
|
|
42
|
+
* ```
|
|
37
43
|
*/
|
|
38
44
|
disable() {
|
|
39
45
|
this._clickZoom.disable();
|
|
@@ -43,7 +49,7 @@ export default class DoubleClickZoomHandler {
|
|
|
43
49
|
/**
|
|
44
50
|
* Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
|
|
45
51
|
*
|
|
46
|
-
* @returns
|
|
52
|
+
* @returns `true` if the "double click to zoom" interaction is enabled.
|
|
47
53
|
*/
|
|
48
54
|
isEnabled() {
|
|
49
55
|
return this._clickZoom.isEnabled() && this._tapZoom.isEnabled();
|
|
@@ -52,7 +58,7 @@ export default class DoubleClickZoomHandler {
|
|
|
52
58
|
/**
|
|
53
59
|
* Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
|
|
54
60
|
*
|
|
55
|
-
* @returns
|
|
61
|
+
* @returns `true` if the "double click to zoom" interaction is active.
|
|
56
62
|
*/
|
|
57
63
|
isActive() {
|
|
58
64
|
return this._clickZoom.isActive() || this._tapZoom.isActive();
|