touchmove在安卓浏览器上只会触发一次,需要preventDefault()

 

touchmove events in Android web browsers have a really serious bug. If you don't include the following code, the touchmove event will fire once, but not again until you're done moving your touch, which utterly kills the usefulness of the touchmove event. It's a weird one, and may very well break more advanced touch logic that works on iOS. But if you preventDefault() on the touchstart event, your touchmove will function as expected.

  
 
  1. element.addEventListener( "touchstart", function(e){ onStart(e); }, false );
  2. function onStart ( touchEvent ) {
  3.   if( navigator.userAgent.match(/Android/i) ) {
  4.     touchEvent.preventDefault();
  5.   }
  6. }

相关文章:

  • 2022-12-23
  • 2021-05-03
  • 2021-10-24
  • 2021-07-26
  • 2021-11-29
  • 2021-07-12
  • 2021-05-24
猜你喜欢
  • 2022-01-20
  • 2022-12-23
  • 2021-05-10
  • 2022-12-23
  • 2021-09-23
  • 2021-09-29
  • 2022-12-23
相关资源
相似解决方案