JS设置页面下拉刷新

JS设置页面下拉刷新

//滑动动作  
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.touches[0];
	startY = touch.pageY;
}  
function touchMove(e){
//	e.preventDefault();
	if(!canefresh){
		return;
	}
	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;
} 


猜你喜欢

转载自blog.csdn.net/qq_16494241/article/details/71660555
今日推荐