6

I have a Google Maps map on my web site, but when using it with a Microsoft Surface tablet, the "pan" gesture is intercepted by the browser -- it tries to go to the next browser window. How do I allow the pan (drag event) to be ignored by the browser so the map behaves normally? Going to maps.google.com, the map is perfectly dragable, so there must be a workaround that Google employs.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
scotts
  • 4,027
  • 3
  • 29
  • 26
  • Did you actually get this to work correctly? I am still facing the same issue and have tried applying the `touch-action` CSS rule on all elements with no luck. – Mark May 20 '15 at 02:28

1 Answers1

12

According to MS's guide on "Pointer and gesture events" (here: http://msdn.microsoft.com/en-us/library/ie/hh673557%28v=vs.85%29.aspx#Panning_and_zooming) you need to add a CSS class to the element you want to disable panning on with the "-ms-touch-action" rule set to "none" like this:

.disablePanZoom 
{
    -ms-touch-action: none; /* Shunt all pointer events to JavaScript code. */
}

--EDIT--

There is now a non-prefixed touch-action property, proposed in the W3C Pointer Events Candidate recomendation.

From the MSDN documentation:

As of Internet Explorer 11, the Microsoft vendor prefixed version of this event (-ms-touch-action) is no longer supported and may be removed in a future release. Instead, use the non-prefixed name touch-action, which is better for standards compliance and future compatibility.

Elad Katz
  • 7,483
  • 5
  • 35
  • 66
JoeDuncan
  • 367
  • 3
  • 8
  • 1
    I would add that you can do both, for maximum compatibility, it doesn't hurt to do this: `.disablePanZoom { -ms-touch-action: none; touch-action: none; }` – JoeDuncan Mar 07 '17 at 01:19