var startY = 0;
document.addEventListener("touchstart",function(e){
startY = e.changedTouches[0].pageY;
},false);
document.addEventListener("touchend",function(e){
var endY = e.changedTouches[0].pageY;
var changeVal = endY - startY;
if(endY < startY){//向上滑
alert('向上滑');
}else if(endY > startY){//向下滑
alert('向下滑');
}else{
alert("没有偏移");
}
},false);
网友评论