码迷,mamicode.com
首页 > 其他好文 > 详细

警告:添加非被动事件侦听器到滚动阻塞'touchstart'事件(Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event han)

时间:2020-12-14 13:18:20      阅读:2      评论:0      收藏:0      [点我收藏+]

标签:pts   add   capture   rop   type   dde   阻塞   使用   cap   

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

警告:添加非被动事件侦听器到滚动阻塞'touchstart'事件(Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event han)

标签:pts   add   capture   rop   type   dde   阻塞   使用   cap   

原文地址:https://www.cnblogs.com/zzsdream/p/14101767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!