javascript - 使用触控板时捕获滚轮/鼠标滚轮事件的边缘替代解决方案

标签 javascript events microsoft-edge

Edge 上存在一个错误,当您使用精密触控板时,滚轮/mousehweel 事件不会触发。

https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7134034/

该问题显示为“已修复”,但尚未修复(在联想笔记本电脑和带有 Edge 最新版本的 Surface Pro 上测试)

有什么办法可以捕获这个事件吗?我尝试使用覆盖元素并捕获滚动事件,它可以工作,但由于该覆盖,您无法单击页面上的任何内容,并且不给它指针事件:none 会禁用滚动事件。

有什么想法吗?

最佳答案

在您指出的未决问题中,Microsoft Edge 团队表示,该问题已通过实现 PTP 指针事件解决,如 this blog post 中所述。 .

In HTML, add the touch-action CSS property to your target element to prevent the browser from executing its default touch behavior in response to gestures:

<canvas height=400 width=400 id="canvas" style="touch-action: none;"></canvas>

In JavaScript, attach a Pointer Event listener to your target element. You can determine the type of pointer that caused the handler to be invoked using the pointerType property of the event object passed into the event listener callback:

document.getElementById('canvas').addEventListener('pointermove', function(event) {
    console.log('pointermove!');
});

您可以引用this doc有关积分事件的更多详细信息。

关于javascript - 使用触控板时捕获滚轮/鼠标滚轮事件的边缘替代解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57776162/

相关文章:

javascript - MongoDB 在匹配的键值对旁边插入数据

javascript - 来自不同文件夹的 Jquery.load URL

javascript - 动态添加完整日历不起作用

javascript - 捕获滚轮事件

mysql - 使用 MySQL 事件到 "deactivate"帐户

c# - 在 C# 中引发外部对象的事件

php - 单击按钮创建 mysql 事件,每 5 分钟删除表的第一行?

mobile - Microsoft Edge 的用户代理字符串名称是什么?

javascript - Edge 浏览器中未定义的 PHP Websocket

c# - 为什么在 Edge 中调试我的 asp.net core 2.0 应用程序时显示 "You' ll 需要一个新的应用程序来打开此本地主机”弹出窗口?