javascript的touchend在android上 执行两次 solution

http://dropshado.ws/post/45694832906/touch-identifier-0 
document.body.addEventListener( 'touchstart', function( event ) {
 
// dismiss after-touches
 
if ( isTouching ) {
   
return;
 
}
 
event.preventDefault();
 
// only care about the first touch
 
var touch = event.changedTouches[0];
  identifier
= touch.identifier;
  log
('touch START; indentifer ' + touch.identifier );
  window
.addEventListener( 'touchmove', onTouchMove, false );
  window
.addEventListener( 'touchend', onTouchEnd, false );
  isTouching
= true;
}, false );

function getTouch( event ) {
 
// cycle through every change touch and get one that matches
 
for ( var i=0, len = event.changedTouches.length; i < len; i++ ) {
   
var touch = event.changedTouches[i];
   
if ( touch.identifier === identifier ) {
     
return touch;
   
}
 
}
}

function onTouchMove( event ) {
 
// get matched touch
 
var touch = getTouch( event );
 
if ( !touch ) {
   
return;
 
}
  log
( 'touch move ' + touch.pageX + ' ' + touch.pageY );
}

你可能感兴趣的:(JavaScript,android,touch,touchEnd,twice)