更新时间:2022-10-30 13:24:46
已使用touchstart,touchend解决
(function(){
var currentPage = 0;
var direction = function(up, down){
var YStack = [];
document.body.addEventListener('touchstart',function(e){
YStack.length = 0;
YStack.push(e.touches[0].clientY);
},false);
document.body.addEventListener('touchend',function(e){
YStack.push(e.changedTouches[0].clientY);
YStack[1]-YStack[0] >= 100?down():void 0;
YStack[1]-YStack[0] <= -100?up():void 0;
},false);
}
var scrollUp = function(){
if(currentPage<=3){
currentPage++;
$('div#wrapper').css({'top':-currentPage+'00%'});
}
}
var scrollDown = function(){
if(currentPage>=1){
currentPage--;
$('div#wrapper').css({'top':-currentPage+'00%'});
}
}
direction(scrollUp,scrollDown);
})();