touchmove Bug 工作遇到

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. }

posted on 2016-01-27 13:34  迷茫小飞侠  阅读(365)  评论(0编辑  收藏  举报

导航