<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
//事件:当屏幕发生滚动的时候
window.onscroll=function(){
//距离页面顶部的滚动的距离
var oScrollTop=document.documentElement.scrollTop || document.body.scrollTop;
//屏幕的可视高度
var oClientH=document.documentElement.clientHeight;
//body的高度
var oBodyH=document.body.scrollHeight || document.documentElement.scrollHeight;
var disabled=false;
/*disabled用于阻止滚动事件多次触发*/
if(oBodyH - oClientH - oScrollTop <= 200){
/*下拉刷新普通版*/
if(disabled){
return false;
}else{
disabled=true;
alert('刷新数据了哦');
disabled=false;
}
/*下拉刷新ajax版*/
//如果你需要ajax调取接口,需要声明一个变量var disabled=true;
/*ajax({
url:xxx,
data:{
},
success:function(res){
disabled=true;
//把新调取来的数据添加到你需要的数组中即可
disabled=false;
}
})*/
}
}
</script>
</head>
<body>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
<div>Is that the end?</div>
</body>
</html>
移动端中使用率较高的上拉刷新
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 近期的项目是使用react+antd-mobile的h5移动网页端的一个程序,其中一个功能是一个展示列表,具有下拉...