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

前端 未结 4 1830
旧巷少年郎
旧巷少年郎 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:14

    The answer from Sergio is correct, add it at the bottom jquery script. If there is issue touchstart and touchmove, just add same code and replace touchstart with touchmove, like this:

    jQuery.event.special.touchstart = {
      setup: function( _, ns, handle ){
        if ( ns.includes("noPreventDefault") ) {
          this.addEventListener("touchstart", handle, { passive: false });
        } else {
          this.addEventListener("touchstart", handle, { passive: true });
        }
      }
    };
    jQuery.event.special.touchmove = {
      setup: function( _, ns, handle ){
        if ( ns.includes("noPreventDefault") ) {
          this.addEventListener("touchmove", handle, { passive: false });
        } else {
          this.addEventListener("touchmove", handle, { passive: true });
        }
      }
    };
    

提交回复
热议问题