Added non-passive event listener to a scroll-blocking 'touchstart' event

前端 未结 4 1715
旧巷少年郎
旧巷少年郎 2021-01-31 16:32

Suddenly today out of nowhere I started getting this one on every page on our website

Added non-passive event listener to a scroll-blocking \'touchstart\' event.         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 17:24

    I am using various events and this seems to solve my use case

    (function () {
        if (typeof EventTarget !== "undefined") {
            let func = EventTarget.prototype.addEventListener;
            EventTarget.prototype.addEventListener = function (type, fn, capture) {
                this.func = func;
                if(typeof capture !== "boolean"){
                    capture = capture || {};
                    capture.passive = false;
                }
                this.func(type, fn, capture);
            };
        };
    }());
    

提交回复
热议问题