带有 Firefox 的 Surface Pro 3 - 具有单点触摸触发器触摸/鼠标事件,而不是滚轮事件
Surface Pro 3 with Firefox - Have single touch trigger touch/mouse events instead of wheel events
仅在配备 Firefox 的 Surface Pro 3 上:
当用一根手指在元素上做出轻扫手势时,浏览器将触发wheel
事件,而不是touchmove
或mousemove
事件。如何停止滚轮行为,并允许单个手指始终被视为触摸/鼠标移动?
因此,我想将单指滑动视为一系列mousemove
或touchmove
,而不是wheel
事件。如果在此元素上滑动,我根本不希望单指滑动来滚动页面。这在Chrome和IE11中很容易做到。这在Firefox中似乎是不可能的。目前我认为这是一个错误,但可能缺少一些东西。
下面是一个简单的示例:
http://codepen.io/simonsarris/pen/PwbdRZ
var can = document.getElementById('can');
can.addEventListener('mousemove', function(e) {
// Will never happen on the Surface Pro 3 in Firefox
// Will happen in IE11 though
console.log('mouseMove')
});
can.addEventListener('touchmove', function(e) {
// Will never happen on the Surface Pro 3 in Firefox
// Will happen in Chrome though
console.log('touchMove')
});
// Stops the window from scrolling in firefox when you swipe on the element
// But stopping this does not allow the single touch gesture to register as mousemove or touchmove events
can.addEventListener('wheel', function(e) {
console.log('wheel')
e.preventDefault();
});
// consider also the 'DOMMouseScroll' event, though preventing this event will not stop firefox from panning the page.
因为我在wheel
中阻止默认,所以当一根手指向上或向下滑动时,滚动页面会停止
如果您在红色框中滑动,则在 Firefox 中会停止窗口滚动,但不会触发鼠标移动或触摸移动事件。(但是,如果您水平而不是垂直滑动,鼠标移动将触发)
触摸事件目前在桌面版 Firefox (36.0.4) 中被禁用,尽管它们在 Metro 模式下运行 Firefox 时或通过 dom.w3c_touch_events.enabled
设置显式启用它们时可以工作。有关更多信息,请参阅有关触摸事件的 MDN 文章。
相关文章:
- 谷歌地图劫持了iphone's滚动(触摸事件)-如何恢复
- 如何在jquery中找到鼠标滚轮/触摸移动事件的走向
- 如何使用纯javascript的移动触摸事件
- 触摸启动事件未在iframe iOS 6中启动
- 如何检测滚动事件是否像在触摸设备上一样只触发一次
- 触摸滑动所有事件
- 移动定时触摸事件
- 模拟html5的触摸事件
- Phonegap/Cordova:如何添加Javascript多点触摸事件
- 如何在AngularJS中监听点击事件,而不是触摸事件
- 我可以让我的网站的内容可编辑区域对安卓股票浏览器上的触摸事件更敏感吗
- 当鼠标也在触摸另一个元素时,d3.js鼠标悬停事件未被触发
- 在 Firefox 中“解析”触摸事件
- 将触摸事件转换为鼠标事件仅每秒有效一次
- 在移动 Safari 上向下拖动时,触摸事件停止触发 - iPad HTML5
- 如何在 javascript 中触发触摸事件
- 为什么触摸事件不在手指按压的中间
- 如何启用离子多点触摸事件
- JavaScript事件.触摸数组
- D3鼠标事件触摸事件,即点击->支持触摸事件