You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/06/03 09:48:44 UTC

[GitHub] [incubator-echarts] chengmanxiang commented on issue #12019: event.js:160 Unable to preventDefault inside passive event listener invocation.

chengmanxiang commented on issue #12019:
URL: https://github.com/apache/incubator-echarts/issues/12019#issuecomment-638088653


   > @yufeng04 chrome56 开始,在 window、document 和 body 上注册的 touchstart 和 touchmove 事件处理函数,会默认为是 passive: true。在这 3 个元素上的 touchstart 和 touchmove 事件处理函数中调用 e.preventDefault() ,会被浏览器忽略掉,并不会阻止默认行为。
   > 那么如何解决这个问题呢?不让控制台提示,而且 preventDefault() 有效果呢?
   > 两个方案:
   > 1、注册处理函数时,用如下方式,明确声明为不是被动的
   > window.addEventListener('touchmove', func, { passive: false })
   > 
   > 2、应用 CSS 属性 touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。
   > touch-action 还有很多选项,详细请参考touch-action
   > 
   > [注]未来可能所有的元素的 touchstart touchmove 事件处理函数都会默认为 passive: true
   > 
   > 内容来源于网络,非个人提出。
   这个测试有效吗?我试了没效果
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org