Microsoft Surface:如何让JavaScript触控/拖拽事件在不被浏览器拦截的情况下工作? [英] Microsoft Surface: How do I allow JavaScript touch/drag events to work without being intercepted by the browser?
问题描述
我在我的网站上有Google Maps地图,但是当它与Microsoft Surface平板电脑一起使用时,浏览器拦截了pan手势 - 它会尝试进入下一个浏览器窗口。如何让浏览器忽略泛(拖动事件),以便地图正常运行?去 maps.google.com
,地图是完全可拖动的,所以必须有一个Google解决方案。
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.
%28v = vs.85%29.aspx#Panning_and_zoomingrel =nofollow noreferrer> http://msdn.microsoft.com/en-us/library/ie/hh673557%28v=vs.85%29.aspx# Panning_and_zooming ),您需要添加一个CSS类到您想禁用平移的元素,并将-ms-touch-action规则设置为none,如下所示:
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--
现在在W3C Pointer Events Candidate recomendation中提出了一个没有前缀的touch-action属性。
There is now a non-prefixed touch-action property, proposed in the W3C Pointer Events Candidate recomendation.
从 MSDN文档:
从Internet Explorer 11开始,Microsoft供应商前缀版本的此事件(-ms-touch-action)不再受支持,并且可能会在未来版本中删除。相反,使用非前缀名称的touch-action,这对于标准符合性和未来的兼容性来说更好。
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.
这篇关于Microsoft Surface:如何让JavaScript触控/拖拽事件在不被浏览器拦截的情况下工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!