HTML5触摸事件,touchstart、touchmove和touchend

http://blog.csdn.net/kaikai4/article/details/46840317

http://blog.csdn.net/fuqinyijiu/article/details/41315123

//例子

$("body").on("touchstart",function(e) {

e.preventDefault();

startX = e.originalEvent.changedTouches[0].pageX,

startY = e.originalEvent.changedTouches[0].pageY;

});

$("body").on("touchmove",function(e) {

e.preventDefault();

moveEndX = e.originalEvent.changedTouches[0].pageX,

moveEndY = e.originalEvent.changedTouches[0].pageY,

X = moveEndX - startX,

Y = moveEndY - startY;

if( Math.abs(X) > Math.abs(Y) && X > 0 ) {

alert("left 2 right");

}

elseif( Math.abs(X) > Math.abs(Y) && X < 0 ) {

alert("right 2 left");

}

elseif( Math.abs(Y) > Math.abs(X) && Y > 0) {

alert("top 2 bottom");

}

elseif( Math.abs(Y) > Math.abs(X) && Y < 0 ) {

alert("bottom 2 top");

}

else{

alert("just touch");

}

});