[英]Cancel IE9 touch scroll event and invoke Mousemove, possible?
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.在装有 IE9 和多点触控屏幕(如 HP TouchSmart)的 Windows 7 计算机上,如果您在高度足以具有滚动条的页面上触摸屏幕并向上或向下移动手指,页面会滚动。 This doesn't seem to fire any
mousemove
event.这似乎不会触发任何
mousemove
事件。 If you touch the screen and initially move left or right instead of up and down it does fire the mousemouse
events.如果您触摸屏幕并最初向左或向右移动而不是向上和向下移动,则会触发
mousemouse
事件。
I wan't to cancel this scrolling and cause the browser to invoke a normal mousemove
event.我不想取消此滚动并导致浏览器调用正常的
mousemove
事件。 Is this possible?这可能吗?
EDIT: There does not appear to be touch events in IE9 Does IE9 support Touch events on Windows 7?编辑:IE9 中似乎没有触摸事件 IE9 是否支持 Windows 7 上的触摸事件?
EDIT 2: A couple other points of interest about this.编辑 2:关于此的其他几个兴趣点。 First is that browsers often fire a
mousewheel
event when scrolling is triggered by a gesture, this can often be caught and cancelled.首先是浏览器经常在手势触发滚动时触发
mousewheel
事件,这通常可以被捕获和取消。 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) { });
其次,在这种特殊情况下,您可以使用此 hack
$(document).bind('mousedown mouseup click dblclick', function (e) { });
防止在 IE9 上滚动$(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.正如黑客有时所做的那样,对我来说没有任何意义 - 使用更少的事件绑定可能是可能的,但我无法很好地访问设备来轻松测试。
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.
但是,您应该能够从滚动事件处理程序中触发 mousemove 事件。
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.我认为您可以尝试防止自动滚动的两件事:将溢出(或溢出-y)设置为隐藏在您的正文元素上或作为您的 onscroll 处理程序的一部分,尝试滚动回您的原点。 Setting body's overflow to hidden will prevent scrolling and hide the scrollbar, but I'm not sure it's what you want.
将 body 的溢出设置为 hidden 会阻止滚动并隐藏滚动条,但我不确定这是你想要的。
尝试触摸事件而不是鼠标事件。
I had the same issue with iPad.我在 iPad 上遇到了同样的问题。 I had to add an e.preventDefault();
我不得不添加一个 e.preventDefault(); to the touchmove event.
到 touchmove 事件。 I did this only to the div where I was tracking interaction, not to the whole page.
我只对跟踪交互的 div 执行此操作,而不是对整个页面执行此操作。
element.ontouchmove = function(e){ e.preventDefault(); };
No idea about your device, but might be worth a try.不知道您的设备,但可能值得一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.