[英]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. 我的网站上有一张谷歌地图地图,但是当它与微软Surface平板电脑一起使用时,浏览器拦截了“平移”手势 - 它试图转到下一个浏览器窗口。 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. 转到maps.google.com
,地图完全可以拖动,因此Google必须采用一种解决方法。
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: 根据MS的“指针和手势事件”指南(此处: http : //msdn.microsoft.com/en-us/library/ie/hh673557%28v=vs.85%29.aspx#Panning_and_zooming ),您需要添加要禁用平移的元素的CSS类,将“-ms-touch-action”规则设置为“none”,如下所示:
.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. 现在有一个非前缀的触摸动作属性,在W3C Pointer Events Candidate推荐中提出。
From the MSDN documentation : 从MSDN文档 :
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. 从Internet Explorer 11开始,不再支持此事件的Microsoft供应商前缀版本(-ms-touch-action),可能会在将来的版本中删除。 Instead, use the non-prefixed name touch-action, which is better for standards compliance and future compatibility. 相反,请使用非前缀名称touch-action,这样可以更好地符合标准和未来的兼容性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.