取消 IE9 触摸滚动事件并调用 Mousemove,可能吗?

发布于 2025-01-03 23:40:13 字数 629 浏览 0 评论 0原文

在装有 IE9 和多点触控屏幕(例如 HP TouchSmart)的 Windows 7 计算机上,如果您在足够高且有滚动条的页面上触摸屏幕并向上或向下移动手指,页面就会滚动。这似乎不会触发任何 mousemove 事件。如果您触摸屏幕并首先向左或向右移动而不是向上或向下移动,则会触发 mousemouse 事件。

我不想取消此滚动并导致浏览器调用正常的 mousemove 事件。这可能吗?

编辑: IE9 中似乎没有触摸事件 IE9 支持触摸吗Windows 7 上的事件?

编辑 2: 关于此的其他一些有趣的点。首先,当手势触发滚动时,浏览器通常会触发鼠标滚轮事件,这通常可以被捕获并取消。其次,在这种特殊情况下,您可以使用以下 hack $(document).bind('mousedown mouseup click dblclick', function (e) { }); 来阻止 IE9 上的滚动有时这样做,对我来说没有任何意义 - 可能可以使用更少的事件绑定,但我无法很好地访问设备来轻松测试。

On a Windows 7 computer with IE9 and a multitouch screen, like an HP TouchSmart, if you touch the screen on a page that is tall enough to have a scrollbar and move your finger up or down the page scrolls. This doesn't seem to fire any mousemove event. If you touch the screen and initially move left or right instead of up and down it does fire the mousemouse events.

I wan't to cancel this scrolling and cause the browser to invoke a normal mousemove event. Is this possible?

EDIT: There does not appear to be touch events in IE9 Does IE9 support Touch events on Windows 7?

EDIT 2:
A couple other points of interest about this. First is that browsers often fire a mousewheel event when scrolling is triggered by a gesture, this can often be caught and cancelled. Second is that in this particular case, you can prevent the scrolling on IE9 with this hack $(document).bind('mousedown mouseup click dblclick', function (e) { }); which as hacks sometimes do, does not make any sense to me - it may be possible to use fewer event bindings but I didn't have good access to a device to easily test.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不甘平庸 2025-01-10 23:40:13

在花了一些时间测试抑制默认事件响应的各种方法之后,我不知道如何抑制滚动事件。但是,您应该能够从滚动事件处理程序中触发 mousemove 事件。

window.onscroll = function(e){
    element.onmousemove();
}

//jquery
$(window).scroll(function(e){ element.mousemove(); } );

一个原始示例

我认为您可以尝试阻止自动滚动的两件事:将溢出(或溢出-y)设置为隐藏在您的 body 元素上或作为 onscroll 处理程序的一部分,尝试滚动回原点。将 body 的溢出设置为隐藏将阻止滚动并隐藏滚动条,但我不确定这是否是您想要的。

After spending some time testing the various methods to suppress default event responses, I have no idea how to suppress the scroll event. You should, however, be able to fire the mousemove event from within a scroll event handler.

window.onscroll = function(e){
    element.onmousemove();
}

//jquery
$(window).scroll(function(e){ element.mousemove(); } );

A primitive example.

Two things I suppose you could try to prevent auto-scroll: setting the overflow (or overflow-y) to hidden on you body element or as part of your onscroll handler, attempting to scroll back to your point of origin. Setting body's overflow to hidden will prevent scrolling and hide the scrollbar, but I'm not sure it's what you want.

合约呢 2025-01-10 23:40:13

尝试触摸事件而不是鼠标事件。

Try touch events instead of mouse events.

吾性傲以野 2025-01-10 23:40:13

我在 iPad 上也遇到了同样的问题。我必须添加一个 e.preventDefault();到 touchmove 事件。我只对跟踪交互的 div 执行此操作,而不对整个页面执行此操作。

element.ontouchmove = function(e){ e.preventDefault(); };

不知道您的设备,但可能值得一试。

I had the same issue with iPad. I had to add an e.preventDefault(); to the touchmove event. I did this only to the div where I was tracking interaction, not to the whole page.

element.ontouchmove = function(e){ e.preventDefault(); };

No idea about your device, but might be worth a try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文