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.
- element.addEventListener( "touchstart", function(e){ onStart(e); }, false );
- function onStart ( touchEvent ) {
- if( navigator.userAgent.match(/Android/i) ) {
- touchEvent.preventDefault();
- }
- }