简体   繁体   English

Microsoft Surface:如何在不被浏览器拦截的情况下允许JavaScript触摸/拖动事件?

[英]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.

相关问题 Android浏览器触摸事件停止显示正在更新公司。帆布/元素 - 如何解决? - Android browser touch events stop display being updated inc. canvas/elements - How to work around? 如何在没有大型图书馆的情况下获得触摸事件 - How do I get touch events without big library 如何将拖动事件限制为Javascript(反应)中的容器div? - How do I restrict drag events to a container div in Javascript (React)? 我怎么能在触摸时做一些事情而不是触摸和拖动 - How can I do something on touch but not on touch and drag 添加 Javascript 触摸事件以拖动 div - Add Javascript touch events to drag divs 如何以及如何禁用JavaScript中的触摸事件? - How and can I disable touch events in Javascript? 如何通过触摸使mootools拖放工作? - How do you make mootools drag and drop work with touch? 如何防止拖累孩子,但允许拖累父母? - How do I prevent drag on a child, but allow drag on the parent? 如何让 JavaScript execCommand("paste") 在 Electron 中工作? - How do I allow JavaScript execCommand("paste") to work in Electron? 如何在浏览器环境中获得活动的触摸事件而不发生触摸事件 - How to get active touch events without having a touch event in a browser environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM