IE多点支持以及html中事件模拟
2018-04-27 本文已影响0人
InnoTech
1.默认ie在触摸屏支持整个页面的缩放手势和滚动,收不到mouse event的事件,如要开启使用:
html { -ms-touch-action: none;}
事件使用:
canvas.addEventListener('MSPointerDown', function (e)
{
});
canvas.addEventListener('MSPointerMove', function (e)
{
});
canvas.addEventListener('MSPointerUp', function (e)
{
});
2.html模拟事件
模拟滚动事件
var evt = document.createEvent("MouseWheelEvent");
evt.initEvent('mousewheel', false, false);
evt.wheelDelta = delta;
window.dispatchEvent(evt);
模拟鼠标事件
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent(type,
e.bubbles, e.cancelable, e.view, e.detail,
e.screenX, e.screenY, e.clientX, e.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
e.button, document.body.parentNode);
window.dispatchEvent(evt);