// 判斷滑動進入上、下頁
function goNext($ele,callback){
var startY , endY , diff;
$ele.on('touchstart',touchStart);
$ele.on('touchmove',touchMove);
$ele.on('touchend',touchEnd);
function touchStart(e){
diff = 0;
var touch = e.originalEvent.targetTouches[0];
startY = touch.pageY;
}
function touchMove(e){
e.preventDefault();
var touch = e.originalEvent.targetTouches[0];
endY = touch.pageY;
diff = endY - startY;
}
function touchEnd(e){
if(Math.abs(diff) > 150){
if(diff< 0){
callback && callback(1);
}else{
callback && callback(2);
}
}
}
}
// 引用
goNext($('.pageone'),(type) => {
type == 1 ? '向上' : '向下';
});