Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Surface: How do I allow JavaScript touch/drag events to work without being intercepted by the browser?

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.

like image 900
scotts Avatar asked Oct 29 '12 21:10

scotts


People also ask

How do you drag on Microsoft Surface?

If you have a pen, the click and drag would be the same as the click and drag with a mouse. If you don't have a pen, you would need to use your finger to click on the icon you want to drag, and without lifting your finger on the screen, drag the icon to the position you want it to be. Hope this helps.

How do I use touch screen on surface?

Like a tablet, you tap and slide your fingers on the Surface touch screen to open apps and access settings. Like a PC, you can enter keystroke shortcuts on the Surface Touch Cover and Type Cover keyboards to reach those same programs and system options.

How do I turn off touch screen on Surface Pro?

Go to Device Manager > Select the arrow next to Human Interface Devices > select HID-compliant touch screen and disable it.


1 Answers

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.

like image 178
JoeDuncan Avatar answered Oct 13 '22 01:10

JoeDuncan