IE多点支持以及html中事件模拟

1.默认ie在触摸屏支持整个页面的缩放手势和滚动,收不到mouse event的事件,如要开启使用:

html { -ms-touch-action: none;}

事件使用:

canvas.addEventListener('MSPointerDown', function (e)

{

});

canvas.addEventListener('MSPointerMove', function (e)

{

});

canvas.addEventListener('MSPointerUp', function (e)

{

});

参看:https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/dev-guides/hh673557(v=vs.85)


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);

你可能感兴趣的:(IE多点支持以及html中事件模拟)