Javascript 使用IE11在Surface Pro 3上没有鼠标滚轮事件?
Windows 8.1上的IE11似乎没有通过精密触摸板上的多点触摸滚动发送鼠标滚轮事件,就像新Surface Pro 3的类型封面上的事件一样。有没有别的活动我可以听?实际的滚动事件不起作用,因为我正在通过捕获输入来模拟画布应用程序中的滚动区域。这是一个错误。在修好之前是没有办法的。我可以确认它可以在Synaptics触摸板和鼠标滚轮上用两个手指滚动正常工作,但不能使用精密触摸板(如Surface Type封面3、4或Surface Book)。这只是Microsoft Edge和Internet Explorer的一个问题。Chrome和Firefox都将精密触摸板的双指滚动与任何其他触摸板的双指滚动完全相同 是以下代码的一部分,用于测试/验证: JS:Javascript 使用IE11在Surface Pro 3上没有鼠标滚轮事件?,javascript,internet-explorer,internet-explorer-11,Javascript,Internet Explorer,Internet Explorer 11,Windows 8.1上的IE11似乎没有通过精密触摸板上的多点触摸滚动发送鼠标滚轮事件,就像新Surface Pro 3的类型封面上的事件一样。有没有别的活动我可以听?实际的滚动事件不起作用,因为我正在通过捕获输入来模拟画布应用程序中的滚动区域。这是一个错误。在修好之前是没有办法的。我可以确认它可以在Synaptics触摸板和鼠标滚轮上用两个手指滚动正常工作,但不能使用精密触摸板(如Surface Type封面3、4或Surface Book)。这只是Microsoft Edge和Intern
你在找什么?如果有人通过鼠标滚轮以外的其他方式(即触摸键或箭头键)滚动页面时触发鼠标滚轮事件,我会感到惊讶。这只是使用键盘下的触摸板,它应该像鼠标滚轮一样工作(在同一台机器上,它在Chrome中工作).您是否测试过IE11是否在触摸板上使用触摸事件而不是鼠标事件?从技术上讲,它是一个触摸界面,即使从历史上看,轨迹板在JS事件中一直被视为鼠标。IE/MS开发者可能已经决定使用Surface触控板进行不同的操作。是的,没有触发touchstart、DOMMouseScroll、mousewheel、touchmove、gesturestart或gesturechange事件。看起来像,但遗憾的是,它不包含任何直接链接到带有答案/解决方案的页面。这是网站。向上投票有助于引起更多的关注。
(function($) {
var $bg = $('.bg'),
$log = $('.log'),
xPos = 0;
// Define wheel event handler:
function onWheelEvent(e) {
// Prevent default behavior of scrolling the web page:
e.preventDefault();
e.stopPropagation();
// Determin the wheel's vertical scroll delta:
var wheelDeltaY = 0;
if ('deltaY' in e) {
if (e.deltaMode === 1) {
wheelDeltaY = ((Math.abs(e.deltaY) < 6) ? e.deltaY * -2 : -e.deltaY) * 20;
} else {
wheelDeltaY = -e.deltaY;
}
} else if ('wheelDeltaY' in e) {
wheelDeltaY = e.wheelDeltaY / 120 * 20;
} else if ('wheelDelta' in e) {
wheelDeltaY = e.wheelDelta / 120 * 20;
} else if ('detail' in e) {
wheelDeltaY = -e.detail / 3 * 20;
} else {
$log.append('<p>unable to determine delta</p>');
}
xPos = xPos + Math.round(wheelDeltaY);
$bg.css('background-position', xPos + 'px 0px');
$log.append('<p>' + e.type + ' event scrolled by ' + wheelDeltaY + 'px. New X position: ' + xPos + '</p>');
$log.scrollTop($log[0].scrollHeight);
};
// Capture wheel events for all browsers
// (I'm not using jQuery's event subscription
// model to show it's not a jQuery problem):
$bg[0].addEventListener('wheel', onWheelEvent, false);
$bg[0].addEventListener('mousewheel', onWheelEvent, false);
$bg[0].addEventListener('DOMMouseScroll', onWheelEvent, false);
})($);
<div class="tall">
<!-- Force browser to show scroll bars -->
<div class="bg">
<!--BG image we'll move horizontally -->
<div class="log">
<!--Contain the event log-->
<h3>Scroll with mouse wheel or 2-finger scrolling here</h3>
<p>
Expected behavior: The background image (which is large and may take a minute to load) should shift horizontally when scrolling over the image, even though the page is tall enough to have a browser-created vertical scrollbar.
</p>
<p>
If you scroll the mouse over this image, and the page scrolls vertically (and this text isn't replaced with an event log), it means the event was not captured.
</p>
</div>
</div>
</div>
.tall {
height: 2000px;
}
.bg {
width: 100%;
height: 300px;
background-image: url(http://i.imgur.com/DP6K9D8.gif);
background-position: 0px 0px;
background-repeat: repeat;
background-repeat-x: repeat;
background-repeat-y: no-repeat;
background-size: contain;
position: relative;
}
.log {
position: absolute;
top: 10px;
right: 10px;
width: 40%;
padding: 10px;
background-color: rgba(255, 255, 255, 0.85);
color: #555;
max-height: 260px;
overflow: hidden;
font-size: 0.7em;
font-family: arial, sans-serif;
}