JS设置页面下拉刷新当前页面

//滑动动作  
// $('body').on('touchstart',touchStart);
// $('body').on('touchmove',touchMove);
// $('body').on('touchend',touchEnd);
document.body.addEventListener("touchstart", touchStart, false);
document.body.addEventListener("touchmove", touchMove, false);
document.body.addEventListener("touchend", touchEnd, false);
var canefresh = false;
function touchStart(e){
if($(window).scrollTop() <= 0){
canefresh = true;
}
// var touch = e.originalEvent.targetTouches[0];
var touch = e.touches[0];
startY = touch.pageY;
}  
function touchMove(e){
// e.preventDefault();
if(!canefresh){
return;
}
// var touch = e.originalEvent.targetTouches[0];
var touch = e.touches[0];
endY = touch.pageY;
$('body').css('padding-top',endY - startY);
}
function touchEnd(e){
if(!canefresh){
return;
}
console.log(endY - startY);
if((endY - startY) > 50){
location.reload();
}
$('body').css('padding-top','');
canefresh = false;
}
 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/21794.html