Skip to content

Adding 'cooperative gestures' as an option when creating a map#1234

Merged
HarelM merged 21 commits intomaplibre:mainfrom
ewagstaff:cooperative-gestures
Jul 3, 2022
Merged

Adding 'cooperative gestures' as an option when creating a map#1234
HarelM merged 21 commits intomaplibre:mainfrom
ewagstaff:cooperative-gestures

Conversation

@ewagstaff
Copy link
Copy Markdown
Contributor

@ewagstaff ewagstaff commented May 13, 2022

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!

This does use the same option name as Mapbox uses, but collaborativeGestures seems to be the standard way to describe this behavior. All of the code was written from scratch.

  • Briefly describe the changes in this PR.

The main additions are in map.ts where I added the option for collaborative gestures when the map is created. If the boolean is true, this update will create a hidden div containing gesture instructions that gets shown and hidden by adding and removing a CSS class.

Small additions were made in scroll_zoom.ts and touch_pan.ts to add the classes to show the div when appropriate.

  • Include before/after visuals or gifs if this PR includes visual changes.

With the option off:
coopoff

With the option on:
coop

  • Write tests for all new functionality.
    I've asked in the #maplibre OSM channel for guidance on how to structure a test of this new option. If a maintainer could point me in the direction of a similar example, a reference would be really helpful.

  • Document any changes to public APIs.

  • Post benchmark scores.
    Maybe my computer is not dialed enough to run these benchmarks, because when I run npm run benchmarks it fires up the processes but hasn't completed after a few hours.

  • Manually test the debug page.

  • Suggest a changelog category: Feature

  • Add an entry inside this element for inclusion in the maplibre-gl-js changelog: <changelog>Added collaborativeGestures option when instantiating map to prevent inadvertent scrolling/panning when navigating a page where map is embedded inline #234 </changelog>.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 14, 2022

Bundle size report:

Size Change: +101 B
Total Size Before: 202 kB
Total Size After: 202 kB

Output file Before After Change
maplibre-gl.js 193 kB 192 kB -138 B
maplibre-gl.css 9.41 kB 9.65 kB +239 B
ℹ️ View Details
Source file Before After Change
src/style-spec/error/validation_error.ts 119 B 3.56 kB +3.45 kB
src/ui/map.ts 6.33 kB 6.76 kB +431 B
node_modules/gl-matrix/esm/quat.js 0 B 158 B +158 B
src/ui/handler/touch_pan.ts 437 B 542 B +105 B
node_modules/earcut/src/earcut.js 2.62 kB 2.72 kB +99 B
src/geo/transform.ts 4.45 kB 4.54 kB +92 B
node_modules/vt-pbf/index.js 872 B 936 B +64 B
src/symbol/symbol_size.ts 575 B 637 B +62 B
src/ui/handler/touch_zoom_rotate.ts 968 B 1.03 kB +61 B
node_modules/gl-matrix/esm/mat4.js 2.76 kB 2.81 kB +49 B
node_modules/gl-matrix/esm/vec4.js 419 B 466 B +47 B
src/util/util.ts 1.83 kB 1.87 kB +39 B
src/source/rtl_text_plugin.ts 858 B 896 B +38 B
node_modules/gl-matrix/esm/vec3.js 813 B 851 B +38 B
src/ui/handler/scroll_zoom.ts 1.25 kB 1.28 kB +33 B
src/data/bucket/pattern_attributes.ts 111 B 138 B +27 B
node_modules/gl-matrix/esm/vec2.js 225 B 252 B +27 B
src/util/performance.ts 785 B 799 B +14 B
src/style-spec/expression/types.ts 500 B 510 B +10 B
src/symbol/symbol_layout.ts 3.63 kB 3.64 kB +10 B
node_modules/@mapbox/whoots-js/index.mjs 273 B 283 B +10 B
src/util/is_char_in_unicode_block.ts 876 B 885 B +9 B
src/data/bucket/fill_bucket.ts 1.09 kB 1.1 kB +9 B
src/data/bucket/circle_bucket.ts 966 B 974 B +8 B
src/util/image.ts 674 B 682 B +8 B
src/render/program/symbol_program.ts 1.29 kB 1.3 kB +8 B
src/data/segment.ts 446 B 453 B +7 B
src/data/feature_position_map.ts 554 B 561 B +7 B
src/style/style_layer/hillshade_style_layer_properties.g.ts 155 B 162 B +7 B
node_modules/@mapbox/vector-tile/lib/vectortilefeature.js 1.01 kB 1.01 kB +7 B
src/data/bucket/fill_extrusion_bucket.ts 1.42 kB 1.43 kB +7 B
src/render/image_atlas.ts 833 B 840 B +7 B
src/data/dem_data.ts 832 B 839 B +7 B
src/render/program/terrain_program.ts 609 B 616 B +7 B
src/render/draw_fill_extrusion.ts 829 B 836 B +7 B
src/symbol/quads.ts 1.88 kB 1.89 kB +6 B
src/style/style_layer/symbol_style_layer.ts 1.02 kB 1.02 kB +6 B
src/source/geojson_worker_source.ts 1.46 kB 1.46 kB +6 B
src/style-spec/diff.ts 1.53 kB 1.54 kB +6 B
src/style/style.ts 6.85 kB 6.86 kB +6 B
src/gl/context.ts 1.28 kB 1.28 kB +6 B
src/ui/handler/handler_util.ts 103 B 109 B +6 B
src/ui/handler_manager.ts 2.46 kB 2.47 kB +6 B
src/style-spec/validate/validate.ts 385 B 390 B +5 B
src/style/load_glyph_range.ts 217 B 222 B +5 B
src/render/line_atlas.ts 983 B 988 B +5 B
src/render/program/circle_program.ts 454 B 459 B +5 B
src/render/program/background_program.ts 475 B 480 B +5 B
src/render/draw_collision_debug.ts 1.13 kB 1.13 kB +5 B
src/ui/hash.ts 934 B 939 B +5 B
src/util/debug.ts 156 B 161 B +5 B
src/style-spec/validate/validate_object.ts 387 B 391 B +4 B
src/util/script_detection.ts 1.65 kB 1.66 kB +4 B
src/style/style_layer/custom_style_layer.ts 485 B 489 B +4 B
src/style/style_layer/hillshade_style_layer.ts 137 B 141 B +4 B
src/data/feature_index.ts 1.74 kB 1.74 kB +4 B
src/symbol/grid_index.ts 1.35 kB 1.35 kB +4 B
src/render/draw_background.ts 567 B 571 B +4 B
src/ui/control/logo_control.ts 502 B 506 B +4 B
src/style-spec/util/interpolate.ts 169 B 172 B +3 B
src/util/intersection_tests.ts 940 B 943 B +3 B
src/data/bucket/line_attributes.ts 118 B 121 B +3 B
src/style/style_layer/line_style_layer.ts 816 B 819 B +3 B
node_modules/tinyqueue/index.js 359 B 362 B +3 B
src/util/throttled_invoker.ts 209 B 212 B +3 B
src/util/global_worker_pool.ts 313 B 316 B +3 B
src/symbol/cross_tile_symbol_index.ts 1.13 kB 1.14 kB +3 B
src/render/program/debug_program.ts 192 B 195 B +3 B
src/render/draw_line.ts 1.04 kB 1.04 kB +3 B
src/ui/control/navigation_control.ts 1.61 kB 1.61 kB +3 B
node_modules/@mapbox/point-geometry/index.js 628 B 630 B +2 B
src/util/ajax.ts 2.37 kB 2.38 kB +2 B
src/style-spec/expression/definitions/index.ts 1.63 kB 1.63 kB +2 B
src/style-spec/validate_style.min.ts 291 B 293 B +2 B
src/util/transferable_grid_index.ts 1.01 kB 1.02 kB +2 B
src/style/properties.ts 1.87 kB 1.88 kB +2 B
src/data/bucket/circle_attributes.ts 92 B 94 B +2 B
src/util/classify_rings.ts 244 B 246 B +2 B
src/style/style_layer/line_style_layer_properties.g.ts 275 B 277 B +2 B
src/util/verticalize_punctuation.ts 584 B 586 B +2 B
src/style/style_layer/symbol_style_layer_properties.g.ts 652 B 654 B +2 B
src/style/style_layer/fill_style_layer.ts 277 B 279 B +2 B
src/geo/lng_lat_bounds.ts 612 B 614 B +2 B
src/util/dispatcher.ts 332 B 334 B +2 B
src/source/image_source.ts 1.11 kB 1.11 kB +2 B
src/source/tile_cache.ts 555 B 557 B +2 B
src/shaders/background_pattern.vertex.glsl.g.ts 224 B 226 B +2 B
src/shaders/circle.fragment.glsl.g.ts 408 B 410 B +2 B
src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts 826 B 828 B +2 B
src/shaders/symbol_icon.vertex.glsl.g.ts 947 B 949 B +2 B
src/render/vertex_array_object.ts 581 B 583 B +2 B
src/render/program/program_uniforms.ts 926 B 928 B +2 B
src/render/draw_debug.ts 1.13 kB 1.13 kB +2 B
src/geo/edge_insets.ts 428 B 430 B +2 B
src/ui/handler/mouse.ts 554 B 556 B +2 B
src/util/webp_supported.ts 373 B 374 B +1 B
src/style-spec/util/extend.ts 83 B 84 B +1 B
src/style-spec/validate/validate_expression.ts 451 B 452 B +1 B
src/style-spec/validate/validate_layer.ts 863 B 864 B +1 B
src/style-spec/validate/validate_image.ts 61 B 62 B +1 B
src/style/style_layer/circle_style_layer.ts 530 B 531 B +1 B
node_modules/@mapbox/vector-tile/lib/vectortile.js 185 B 186 B +1 B
node_modules/@mapbox/vector-tile/index.js 90 B 91 B +1 B
node_modules/ieee754/index.js 563 B 564 B +1 B
src/symbol/anchor.ts 170 B 171 B +1 B
src/util/find_pole_of_inaccessibility.ts 686 B 687 B +1 B
src/data/bucket/symbol_bucket.ts 4.26 kB 4.26 kB +1 B
src/style/style_layer/heatmap_style_layer.ts 351 B 352 B +1 B
src/style/style_layer/raster_style_layer.ts 66 B 67 B +1 B
node_modules/geojson-vt/src/transform.js 271 B 272 B +1 B
node_modules/geojson-vt/src/index.js 1.56 kB 1.57 kB +1 B
src/source/worker.ts 955 B 956 B +1 B
src/render/texture.ts 681 B 682 B +1 B
src/source/vector_tile_source.ts 1.11 kB 1.11 kB +1 B
src/util/offscreen_canvas_supported.ts 154 B 155 B +1 B
src/source/video_source.ts 874 B 875 B +1 B
src/source/query_features.ts 1.21 kB 1.21 kB +1 B
src/style-spec/empty.ts 155 B 156 B +1 B
src/shaders/debug.fragment.glsl.g.ts 147 B 148 B +1 B
src/shaders/fill.vertex.glsl.g.ts 173 B 174 B +1 B
src/shaders/hillshade.fragment.glsl.g.ts 554 B 555 B +1 B
src/render/program/clipping_mask_program.ts 106 B 107 B +1 B
src/render/program/heatmap_program.ts 559 B 560 B +1 B
src/gl/vertex_buffer.ts 540 B 541 B +1 B
src/render/draw_raster.ts 1.04 kB 1.04 kB +1 B
src/render/draw_custom.ts 333 B 334 B +1 B
src/util/throttle.ts 142 B 143 B +1 B
src/ui/handler/keyboard.ts 570 B 571 B +1 B
src/ui/control/geolocate_control.ts 2.26 kB 2.26 kB +1 B
src/index.ts 866 B 867 B +1 B
src/style-spec/expression/is_constant.ts 255 B 254 B -1 B
src/style-spec/expression/index.ts 1.6 kB 1.6 kB -1 B
src/style-spec/validate/validate_number.ts 221 B 220 B -1 B
src/style-spec/validate/validate_enum.ts 210 B 209 B -1 B
src/style-spec/validate/validate_terrain.ts 241 B 240 B -1 B
src/util/web_worker_transfer.ts 952 B 951 B -1 B
src/data/extent.ts 32 B 31 B -1 B
src/data/load_geometry.ts 255 B 254 B -1 B
src/data/evaluation_feature.ts 96 B 95 B -1 B
src/data/bucket/pattern_bucket_features.ts 325 B 324 B -1 B
src/style/style_layer/fill_extrusion_style_layer_properties.g.ts 191 B 190 B -1 B
src/style/style_layer/fill_extrusion_style_layer.ts 923 B 922 B -1 B
src/symbol/check_max_angle.ts 286 B 285 B -1 B
src/symbol/clip_line.ts 301 B 300 B -1 B
src/symbol/collision_feature.ts 377 B 376 B -1 B
src/util/dictionary_coder.ts 153 B 152 B -1 B
src/util/vectortile_to_geojson.ts 251 B 250 B -1 B
node_modules/kdbush/src/sort.js 376 B 375 B -1 B
node_modules/supercluster/index.js 2.07 kB 2.07 kB -1 B
node_modules/geojson-vt/src/convert.js 852 B 851 B -1 B
node_modules/@mapbox/mapbox-gl-supported/index.js 975 B 974 B -1 B
src/style-spec/util/deep_equal.ts 194 B 193 B -1 B
src/util/request_manager.ts 352 B 351 B -1 B
node_modules/@mapbox/tiny-sdf/index.js 1.1 kB 1.1 kB -1 B
src/source/load_tilejson.ts 272 B 271 B -1 B
src/source/raster_dem_tile_source.ts 971 B 970 B -1 B
src/source/tile.ts 1.99 kB 1.99 kB -1 B
src/data/bucket.ts 195 B 194 B -1 B
src/source/source_state.ts 603 B 602 B -1 B
src/style-spec/deref.ts 208 B 207 B -1 B
src/symbol/collision_index.ts 1.64 kB 1.64 kB -1 B
src/shaders/background_pattern.fragment.glsl.g.ts 296 B 295 B -1 B
src/shaders/debug.vertex.glsl.g.ts 163 B 162 B -1 B
src/shaders/hillshade_prepare.fragment.glsl.g.ts 501 B 500 B -1 B
src/render/program.ts 1.14 kB 1.14 kB -1 B
src/gl/index_buffer.ts 297 B 296 B -1 B
src/gl/color_mode.ts 173 B 172 B -1 B
src/gl/stencil_mode.ts 153 B 152 B -1 B
src/render/render_to_texture.ts 866 B 865 B -1 B
src/ui/handler/shim/dblclick_zoom.ts 150 B 149 B -1 B
src/ui/handler/shim/drag_pan.ts 221 B 220 B -1 B
src/ui/handler/shim/touch_zoom_rotate.ts 292 B 291 B -1 B
src/ui/anchor.ts 218 B 217 B -1 B
src/ui/marker.ts 2.88 kB 2.88 kB -1 B
node_modules/@mapbox/unitbezier/index.js 426 B 424 B -2 B
src/util/config.ts 85 B 83 B -2 B
src/style-spec/expression/scope.ts 195 B 193 B -2 B
src/style-spec/util/color.ts 319 B 317 B -2 B
src/style-spec/expression/stops.ts 189 B 187 B -2 B
src/style-spec/validate/validate_paint_property.ts 54 B 52 B -2 B
src/style-spec/validate/validate_glyphs_url.ts 171 B 169 B -2 B
src/style/style_layer/circle_style_layer_properties.g.ts 229 B 227 B -2 B
src/data/bucket/heatmap_bucket.ts 80 B 78 B -2 B
src/symbol/one_em.ts 32 B 30 B -2 B
src/symbol/merge_lines.ts 403 B 401 B -2 B
src/util/resolve_tokens.ts 97 B 95 B -2 B
src/style/style_layer/raster_style_layer_properties.g.ts 173 B 171 B -2 B
src/geo/mercator_coordinate.ts 348 B 346 B -2 B
node_modules/kdbush/src/index.js 372 B 370 B -2 B
src/symbol/projection.ts 1.82 kB 1.82 kB -2 B
src/symbol/placement.ts 4.8 kB 4.8 kB -2 B
src/style/pauseable_placement.ts 598 B 596 B -2 B
src/shaders/shaders.ts 1.49 kB 1.49 kB -2 B
src/shaders/circle.vertex.glsl.g.ts 559 B 557 B -2 B
src/shaders/fill.fragment.glsl.g.ts 178 B 176 B -2 B
src/shaders/hillshade_prepare.vertex.glsl.g.ts 192 B 190 B -2 B
src/shaders/raster.vertex.glsl.g.ts 202 B 200 B -2 B
src/render/program/collision_program.ts 724 B 722 B -2 B
src/gl/value.ts 1.09 kB 1.09 kB -2 B
src/gl/cull_face_mode.ts 154 B 152 B -2 B
src/render/draw_symbol.ts 2.59 kB 2.59 kB -2 B
src/render/draw_fill.ts 1.01 kB 1.01 kB -2 B
src/render/draw_circle.ts 616 B 614 B -2 B
src/ui/handler/tap_recognizer.ts 536 B 534 B -2 B
src/util/task_queue.ts 268 B 266 B -2 B
src/util/smart_wrap.ts 234 B 232 B -2 B
src/ui/popup.ts 1.91 kB 1.91 kB -2 B
src/style-spec/validate/validate_color.ts 141 B 138 B -3 B
src/util/color_ramp.ts 321 B 318 B -3 B
src/style/style_layer/fill_style_layer_properties.g.ts 195 B 192 B -3 B
src/symbol/shaping.ts 3.62 kB 3.62 kB -3 B
src/geo/lng_lat.ts 588 B 585 B -3 B
src/style/light.ts 559 B 556 B -3 B
src/source/tile_bounds.ts 318 B 315 B -3 B
src/data/raster_bounds_attributes.ts 96 B 93 B -3 B
src/source/source_cache.ts 3.99 kB 3.99 kB -3 B
src/symbol/path_interpolator.ts 311 B 308 B -3 B
node_modules/gl-matrix/esm/mat3.js 224 B 221 B -3 B
src/render/program/raster_program.ts 561 B 558 B -3 B
src/ui/handler_inertia.ts 821 B 818 B -3 B
src/ui/handler/tap_drag_zoom.ts 485 B 482 B -3 B
src/style-spec/expression/types/collator.ts 207 B 203 B -4 B
src/style-spec/expression/runtime_error.ts 113 B 109 B -4 B
src/style/zoom_history.ts 182 B 178 B -4 B
src/data/bucket/line_bucket.ts 2.42 kB 2.41 kB -4 B
src/symbol/transform_text.ts 206 B 202 B -4 B
src/symbol/get_anchors.ts 576 B 572 B -4 B
src/style/format_section_override.ts 308 B 304 B -4 B
src/ui/handler/tap_zoom.ts 368 B 364 B -4 B
src/style-spec/validate/validate_constants.ts 116 B 111 B -5 B
src/render/image_manager.ts 1.4 kB 1.4 kB -5 B
src/render/painter.ts 4.03 kB 4.02 kB -5 B
src/ui/camera.ts 3 kB 3 kB -5 B
src/ui/control/scale_control.ts 742 B 737 B -5 B
src/shaders/encode_attribute.ts 86 B 80 B -6 B
src/style/query_utils.ts 488 B 482 B -6 B
src/style/style_layer/heatmap_style_layer_properties.g.ts 141 B 135 B -6 B
src/data/bucket/fill_attributes.ts 118 B 112 B -6 B
src/render/program/hillshade_program.ts 886 B 880 B -6 B
src/render/program/line_program.ts 1.16 kB 1.16 kB -6 B
src/render/draw_terrain.ts 1.8 kB 1.8 kB -6 B
src/style/style_layer/background_style_layer_properties.g.ts 116 B 109 B -7 B
src/render/glyph_manager.ts 955 B 948 B -7 B
src/render/draw_heatmap.ts 1.04 kB 1.03 kB -7 B
node_modules/csscolorparser/csscolorparser.js 2.06 kB 2.05 kB -8 B
node_modules/murmurhash-js/index.js 76 B 67 B -9 B
src/data/bucket/fill_extrusion_attributes.ts 134 B 125 B -9 B
src/source/tile_id.ts 1.15 kB 1.14 kB -10 B
src/data/array_types.g.ts 2.82 kB 2.81 kB -11 B
node_modules/pbf/index.js 2.82 kB 2.81 kB -11 B
node_modules/quickselect/index.js 360 B 348 B -12 B
src/render/program/fill_program.ts 573 B 560 B -13 B
src/style-spec/expression/definitions/var.ts 336 B 321 B -15 B
src/style-spec/expression/definitions/within.ts 1.38 kB 1.37 kB -16 B
src/source/terrain_source_cache.ts 978 B 961 B -17 B
src/style-spec/expression/types/resolved_image.ts 151 B 132 B -19 B
src/style-spec/expression/definitions/image.ts 296 B 275 B -21 B
node_modules/murmurhash-js/murmurhash3_gc.js 371 B 350 B -21 B
src/style-spec/expression/definitions/in.ts 449 B 425 B -24 B
node_modules/gl-matrix/esm/mat2.js 227 B 203 B -24 B
src/style-spec/expression/definitions/at.ts 399 B 374 B -25 B
src/render/uniform_binding.ts 647 B 621 B -26 B
src/util/tile_request_cache.ts 930 B 902 B -28 B
src/style-spec/expression/compound_expression.ts 761 B 733 B -28 B
src/style-spec/expression/definitions/comparison.ts 871 B 841 B -30 B
src/style/parse_glyph_pbf.ts 397 B 367 B -30 B
src/style-spec/expression/definitions/coalesce.ts 457 B 422 B -35 B
src/style-spec/expression/definitions/length.ts 370 B 334 B -36 B
src/style-spec/expression/definitions/case.ts 472 B 434 B -38 B
src/style-spec/expression/definitions/let.ts 474 B 435 B -39 B
src/style/create_style_layer.ts 387 B 343 B -44 B
src/style-spec/expression/definitions/collator.ts 434 B 386 B -48 B
src/style-spec/expression/definitions/slice.ts 492 B 444 B -48 B
src/style-spec/expression/definitions/step.ts 692 B 643 B -49 B
src/style-spec/util/color_spaces.ts 810 B 757 B -53 B
src/style-spec/expression/definitions/interpolate.ts 1.32 kB 1.26 kB -54 B
src/style-spec/expression/definitions/index_of.ts 549 B 491 B -58 B
src/style-spec/expression/definitions/format.ts 729 B 651 B -78 B
src/style-spec/expression/definitions/number_format.ts 605 B 526 B -79 B
src/style-spec/expression/definitions/literal.ts 395 B 314 B -81 B
src/render/terrain.ts 2.27 kB 2.17 kB -90 B
src/style-spec/util/ref_properties.ts 160 B 68 B -92 B
src/style-spec/expression/definitions/assertion.ts 680 B 584 B -96 B
src/style-spec/expression/definitions/coercion.ts 804 B 705 B -99 B
src/render/program/fill_extrusion_program.ts 801 B 689 B -112 B
src/style-spec/expression/types/formatted.ts 413 B 265 B -148 B
src/style-spec/expression/definitions/match.ts 906 B 751 B -155 B
src/util/primitives.ts 1 kB 728 B -274 B
src/util/evented.ts 3.94 kB 508 B -3.44 kB

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented May 14, 2022

Thanks for taking the time to open this PR!
What would happen for pinch-zoom and two finger pitch change if this is set to true?
Same question for control + mouse drag to change pitch on desktop?

Did you test this on a map that is not full screen and made sure it behaves as expected as this is probably the main use case for this feature?

@ewagstaff
Copy link
Copy Markdown
Contributor Author

Thanks for taking the time to open this PR! What would happen for pinch-zoom and two finger pitch change if this is set to true? Same question for control + mouse drag to change pitch on desktop?

Did you test this on a map that is not full screen and made sure it behaves as expected as this is probably the main use case for this feature?

Pinch-zoom and two-finger pitch change would be unaffected, because they would both successfully pass the requirement of 2 minimum touches to bypass the instruction screen.

Yep, here's a quick gif of an inline that that demonstrates how the new feature enables navigation without getting stuck on the map:
ezgif-4-9fc55ac5f2

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented May 17, 2022

Can you share a stackblitz with this version so I can try it out?
From my understanding panning the map from bottom to upper part should be problematic on mobile, but I need to test it...

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented May 17, 2022

I suggest to run
npm run lint -- --fix
before commiting to fix easy lint errors.

@ewagstaff
Copy link
Copy Markdown
Contributor Author

Lint commands are returning without errors and I have a demo with the build files posted here: https://js-ewvhew.stackblitz.io

@wipfli
Copy link
Copy Markdown
Contributor

wipfli commented May 17, 2022

Thanks at @ewagstaff. I tried the demo on mobile and instead of panning, the map pitched when I used two fingers.

@ewagstaff
Copy link
Copy Markdown
Contributor Author

ewagstaff commented May 17, 2022

Thanks at @ewagstaff. I tried the demo on mobile and instead of panning, the map pitched when I used two fingers.

Ah @wipfli I do see what you mean. Typically I have that gesture disabled. Is there a difference between what you'd expect to do for pitch change vs panning vertically in terms of how your fingers would move in a cooperative gesture setup? (Or should enabling coop gestures disable 2-finger pitch control?)

@wipfli
Copy link
Copy Markdown
Contributor

wipfli commented May 18, 2022

I also usually turn pitch off. The gestures for pitch and pan vertically are the same for me.

@wipfli
Copy link
Copy Markdown
Contributor

wipfli commented May 18, 2022

I wouldn't enforce something like a mutex. But maybe add a comment in the description

@wipfli
Copy link
Copy Markdown
Contributor

wipfli commented May 18, 2022

I would let the user decide the settings freely. We can help them by telling about the pitch stuff in the description of the feature. Would also be great to add an example to the docs website and mention pitch there.

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented May 18, 2022

Even if we let the user decide we still have a feature that contradicts another feature.
If someone would like to allow pitch and this feature there's no way for this to work correctly.
This is a problem from my point of view that needs to be fixed or addressed before this can be merged.

@ewagstaff
Copy link
Copy Markdown
Contributor Author

Looking at other examples deployed live, both Google and Mapbox use a three-finger pitch gesture when cooperative gestures is enabled. What are your thoughts about that adjustment?

@ewagstaff
Copy link
Copy Markdown
Contributor Author

@acalcutt thanks for catching this, please try the demo site again when you can: https://js-ewvhew.stackblitz.io/

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented Jun 19, 2022

This seems to work good in general I think. All controls are working in desktop and mobile (need 3 fingers to change pitch which is acceptable I guess).
The only problem I see is that when I surf to this page from a mobile device (Android Chrome) I get the "use control + scroll" to zoom the map instead of use 2 fingers to pan the map...
Other than that, changelog entry is needed and tests are needed to cover these scenarios.

@ewagstaff
Copy link
Copy Markdown
Contributor Author

@HarelM what device are you seeing that on? I see the "two fingers" language both on my iPhone 12 using Safari and an Android Galaxy Tab A using Chrome. It should swap out the language based on hover feature detection, and that should be supported pretty broadly.

For the changelog, I suggested this language: <changelog>Added collaborativeGestures option when instantiating map to prevent inadvertent scrolling/panning when navigating a page where map is embedded inline #234 </changelog>

To add that, would I just update the CHANGELOG.md file in the repo? Should I increment the version to 2.1.9?

Working on adding test cases now.

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented Jun 19, 2022

No need to increment version.
Yes, simply edit the top most entries in the change log, those without the version.
I have an Android 12, chrome, Samsung Galaxy S20.

@ewagstaff
Copy link
Copy Markdown
Contributor Author

I've added cooperative_gestures.test.ts in the src/ui folder, and it's passing when I run it individually. However, I'm unfamiliar with Jest -- does the file's presence in that directory include it in the pre-build test logic, or does it need to be explicitly added somewhere?

I've updated the changelog, and I added an additional media query check to display the "2 finger" language on any screen smaller than 480px if the feature media query fails. The demo should work on your S20 as expected: https://js-ewvhew.stackblitz.io/

@HarelM
Copy link
Copy Markdown
Collaborator

HarelM commented Jun 20, 2022

Yes, tests that are in the src folder are automatically picked up in the unit test run.
I've tested now with my android mobile, windows and mac desktop and they all work as expected.
Good job @ewagstaff!!

@ewagstaff
Copy link
Copy Markdown
Contributor Author

Per your suggestion @HarelM I added the GestureOptions type and used union types when defining the property. Let me know if that looks correct.

@HarelM HarelM merged commit 557cbcb into maplibre:main Jul 3, 2022
BergkampHUN added a commit to BergkampHUN/ngx-maplibre-gl that referenced this pull request Oct 17, 2022
This feature was added to maplibre few months ago. maplibre/maplibre-gl-js#1234
HarelM pushed a commit to maplibre/ngx-maplibre-gl that referenced this pull request Oct 17, 2022
@HarelM HarelM linked an issue Dec 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapLibre GL JS Default Scrolling Behavior Proposal

4 participants