var passiveEvent = false;
try {
    var opts = Object.defineProperty({}, 'passive', {
        get: function () {
            passiveEvent = true;
        }
    });
    window.addEventListener("test", null, opts);
} catch (e) { }

// in my case I need both passive and capture set to true, change as you need it.
    passiveEvent = passiveEvent ? { capture: true, passive: true } : true;

//if you need to handle mouse wheel scroll
var supportedWheelEvent: string = "onwheel" in HTMLDivElement.prototype ? "wheel" :
    document.onmousewheel !== undefined ? "mousewheel" : "DOMMouseScroll";

使用:
elementRef.addEventListener("touchstart", handler, passiveEvent);

相关文章:

  • 2022-12-23
  • 2021-11-26
  • 2021-05-21
  • 2021-10-16
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案