Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 11.3 beta 1 breaks map panning & zooming #6095

Closed
carvin opened this issue Feb 4, 2018 · 6 comments
Closed

iOS 11.3 beta 1 breaks map panning & zooming #6095

carvin opened this issue Feb 4, 2018 · 6 comments
Assignees

Comments

@carvin
Copy link

carvin commented Feb 4, 2018

In iOS 11.3 beta 1, panning and zooming the map results in incorrect behavior. Panning the map vertically scrolls the web page at the same time, whereas in previous versions of iOS, only the map would move (expected behavior.) In addition, zooming the map zooms the entire web page instead of zooming in on the Mapbox map.

Using Mapbox GL JS version 0.44:

Steps to Trigger Behavior

  1. Upgrade an iPhone or other iOS device to iOS 11.3 beta 1.
  2. Navigate to a web page that includes a Mapbox GL JS map. Some examples I tried:
  1. Pan the map up or down, or try to zoom the map.

Expected Behavior

  • When panning a Mapbox map on a webpage, the map should move without the entire webpage moving.
  • I should be able to zoom a Mapbox map using two fingers without the entire webpage moving.

Correct behavior on iOS 11.2.5

correct

Actual Behavior

  • When panning the map, the entire webpage scrolls as well.
  • When zooming the map, the entire webpage zooms as well.

Incorrect behavior on iOS 11.3 beta 1 and iOS 11.3 beta 2

incorrect

To show that this is a Mapbox-specific issue, here's an example of a Google Maps map working as expected on the same device:

View recording

@korywka
Copy link
Contributor

korywka commented Feb 9, 2018

@carvin I don't use beta, but have the same scroll with ios 11.2.5 on your website. When photo-carousel is set to display: none, the whole page stops scrolling. Maybe you have the same issue?

@carvin
Copy link
Author

carvin commented Feb 11, 2018

@Bravecow Possible there's a separate issue on my site, so let's just use Mapbox's site as an example:

Mapbox Streets

Correct behavior on iOS 11.2.5

correct

Incorrect behavior on iOS 11.3 beta 1 and iOS 11.3 beta 2

incorrect

@carvin
Copy link
Author

carvin commented Feb 11, 2018

Ok, I've found a solution that works for my site. It feels hacky but it's getting the job done for now. I'm tracking when any touch begins and ends on the map canvas. If, while the user is interacting with the map, the page detects a "touch move" event on any element beside the map, I prevent that touch move from being registered.

Here's my workaround (using jQuery):

//Global var tracks whether map is being touched
var touchingMap = false;

//When the Mapbox canvas is touched, adjust the global tracking var
$(document).on("touchstart","canvas",function(e){
  touchingMap = true;
});

//When the Mapbox canvas is no longer being touched, adjust the global tracking var
$(document).on("touchend","canvas",function(e){
  if(e.touches.length == 0){
    touchingMap = false;
  }
});

//When any touch move event happens fire this:
$("*").on("touchmove",function(e){
  //If the map is currently being touched, block any touch move event except those coming from the map.
  if(touchingMap && !($(this).prop("tagName").toLowerCase() == "canvas")){
    e.preventDefault();
  }
});

@jfirebaugh
Copy link
Contributor

@mikew
Copy link

mikew commented Apr 3, 2018

This issue has been closed for just over a month, but it's not out on NPM. Is there any word on when the next release will be?

@anandthakker
Copy link
Contributor

A v0.44.2 patch release fixing this issue is in flight now.

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

No branches or pull requests

5 participants