mapbox / mapbox/mapbox-gl-js

Default pinch-to-zoom browser behaviour should not be blocked when map is maximally zoomed out

Open
#6,793 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 0.44.2

**browser**: Chrome / Safari / (and possibly all other browsers)

### Steps to Trigger Behavior

1. On a mobile device go to http://output.jsbin.com/bobaki/5
2. Zoom in (using pinch-to-zoom gesture) on a button and click it
3. Try to zoom out to see whole page

### Link to Demonstration

http://output.jsbin.com/bobaki/5

### Expected Behavior

When map is maximally zoomed out, it should not block the default browser behaviour and allow to zoom out the browser view.

### Actual Behavior

User can get trapped inside of a map with no way to recover (other than reloading the page, which can also get tricky if the browser bar auto-hides).

### Workaround
There is no way (that I know of) to detect user zoom, so there is no way to act on that. Instead I thought I'll create an escape hatch that will allow users to zoom out the page when mapbox reaches minimal zoom. Unfortunately:
- mapbox doesn't tell you if user is zooming in or out on 'zoom(start)' event,
- mapbox doesn't seem to have a reliable way of checking if user reached minimal zoom level (`getZoom() <= getMinimalZoom()` doesn't work because theoretical minimal zoom level is 0, while actual one seems to be screen/map size dependent and almost never 0),
- there is no way to prevent default mapbox behaviour from event callback (e.g. stop mapbox from `preventDefault`ing pinch-to-zoom gesture).

There are ways to work around those limitations, but the solution gets really nasty.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior on a mobile device with http://output.jsbin.com/bobaki/5, then trace the map's pinch-to-zoom and minimal-zoom handling. Verify how the map distinguishes continued map zooming from the browser's default page zoom. Done means the browser can zoom out once the map is maximally zoomed out without trapping the user in the map.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.