Iscrool下拉刷新
2024-09-25 20:33:57
简易下拉刷新
css样式:
*{
margin: 0px;
padding: 0px; }
#wrapper{
width: 100%;
height: 150px;
border: 1px solid red;
overflow: hidden;
position: absolute;
}
#shua{
text-align: center;
}
HTML代码
<div id="wrapper">
<div>
<div id="shua">刷新</div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
</div>
</div>
在写js代码之前,要引入jQuery插件和 iscroll插件
然后js代码如下: <script type="text/javascript">
//给内容添加滚动事件
var a=new IScroll("#wrapper",{
scrollbars:true,
mouseWheel:true,
interactiveScrollbars:true,
// scrollX:true,
// freeScroll:true,
probeType:2,
})
//让文字先隐藏
$("#shua").hide();
var x=0;
a.on("scroll",function(){
if(x==0){
if(this.y>40){
$("#shua").show();
$("#shua").text("松开手进行刷新")
x=1;
}
a.on("scrollEnd",function(){
if(x==1){
$("#shua").text("正在刷新")
setTimeout(shuju,1000)
x=2;
}
})
var z=0;
function shuju(){
if(x==2){
$("#shua").hide();
$("ul>li:nth-child(1)").before($("<li></li>").text("数据"+ z++))
a.refresh()
x=0;
} }
} })
</script>
这样就完成了一个简单的下拉刷新!!
最新文章
- linux jexus 服务 设置开机启动
- Uiautomator 2.0之BySelector类学习小记
- Windows Azure Storage图形界面管理工具
- Study on Algorithm of Selecting Safe Landing Area on Ground During Asteroid Soft Landing (EEIC2013 +161)
- IPv4&;IPv6双重协议栈
- VsFTP+本地文件认证+SSl实现虚拟用户配置
- Oracle 事务相关的一些测试
- 解决IE11不能进行webTest脚本录制的方法
- 转载:修改xshell中文乱码的问题(管用)
- 第39篇 免费博客github Pages绑定域名
- Linux发行版 CentOS6.5 修改默认主机名
- select选中获取索引三种写法
- JDK10安装配置详解
- 小马哥STM32课程系列
- 电子签名在K2中的应用
- Numpy - Pandas - Matplot 功能与函数名 速查
- debian、ubuntu:使用apt包管理器可能存在的问题! 让新手望而却步!
- HDFS高可用性及其分布式系统思想基础
- log4net始终占用日志文件的问题
- Windows server 2012 R2开机进入cmd,关闭后黑屏问题
热门文章
- CodeForces - 233A Perfect Permutation
- 如何在SQLServer中处理每天四亿三千万记录的(数据库大数据处理)
- Javascript 中 的坑..
- abp使用redis缓存
- Myeclipse经常弹出Subversion Native Library Not Available
- Magic Odd Square (思维+构造)
- Axure8.0
- PIE SDK元素事件的监听
- linux + eclipse C语言 开发环境搭建
- spark第七篇:Spark SQL, DataFrame and Dataset Guide