1 var a = 0; 2 $(window).on('touchstart' , function(e){ 3 a = e.touches[0].screenY; 4 }); 5 $(window).on('touchmove' , function(e){ 6 var disY = e.touches[0].screenY - a; 7 if(disY > 0){ 8 alert('向下') 9 }else{ 10 alert('向上') 11 } 12 }
1 var a = 0; 2 $(window).on('touchstart' , function(e){ 3 a = e.touches[0].screenY; 4 }); 5 $(window).on('touchmove' , function(e){ 6 var disY = e.touches[0].screenY - a; 7 if(disY > 0){ 8 alert('向下') 9 }else{ 10 alert('向上') 11 } 12 }