//移动端滑动事件
function touchJS(prev, next) {
var windowHeight =
(window).height(),
(
w
i
n
d
o
w
)
.
h
e
i
g
h
t
(
)
,
body =
(“body”);
(
“
b
o
d
y
”
)
;
body.css(“height”, windowHeight);
var startX, startY, moveEndX, moveEndY, X, Y;
$("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");
$('#page').animate({ left: '100px'}).fadeIn("slow");
window.location.href = prev;
}
else if (Math.abs(X) > Math.abs(Y) && X < 0) {//右滑
// alert("right 2 left");
$('#page').animate({ right: '100px'}).fadeIn("slow");
window.location.href = next;
}
// else if (Math.abs(Y) > Math.abs(X) && Y > 0) { //上滑
// alert("top 2 bottom");
// }
// else if (Math.abs(Y) > Math.abs(X) && Y < 0) { //下滑
// alert("bottom 2 top");
// }
// else {
// alert("just touch");
// }
$('#page').css("ma", "translate3d(" + moveX + "px,0,0)");
// $('#page').off('touchmove');
});
};