Skip to content

Commit

Permalink
0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ximan committed Dec 5, 2016
1 parent 6ac2612 commit 50d5776
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 39 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.9.1(161205)

* 修复不调用loadDownFn报错bug
* 修复窗口改变resize未触发加载数据bug

### 0.9.0(160215)

* 删除`dropReload()` API,功能集成到之前`resetload()`
Expand Down
4 changes: 4 additions & 0 deletions Intro.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.9.1(161205)

感谢交流群和github上的网友反馈和建议,修复两个bug。并且把某些demo里ajax获取数据部分从原来的假json改为真正的数据接口,让例子更接近线上开发环境。

### 0.9.0(160215)

年前把tab例子加上来让群友测试,果然群众的力量是伟大的!立马就检测出来bug,我当即修复好,只是用法比较复杂,暂时还想不出更方便的办法。顺便把上个版本的`dropReload()` API删掉,功能集成到之前`resetload()`里。另外还修复一个朋友发现的只调用下拉刷新,代码判断bug。
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ a javascript implementation of pull to refresh and up to loadmore

## 背景介绍 (introduce)

年前把tab例子加上来让群友测试,果然群众的力量是伟大的!立马就检测出来bug,我当即修复好,只是用法比较复杂,暂时还想不出更方便的办法。顺便把上个版本的`dropReload()` API删掉,功能集成到之前`resetload()`里。另外还修复一个朋友发现的只调用下拉刷新,代码判断bug
感谢交流群和github上的网友反馈和建议,修复两个bug。并且把某些demo里ajax获取数据部分从原来的假json改为真正的数据接口,让例子更接近线上开发环境

[历史背景介绍](Intro.md)

## 最新版本 (The latest version)

### 0.9.0(160215)
### 0.9.1(161205)

* 删除`dropReload()` API,功能集成到之前`resetload()`
* 优化`noData()``noData(false)`为有数据
* 修复只调用下拉刷新,不调用上拉加载更多bug
* 修复不调用loadDownFn报错bug
* 修复窗口改变resize未触发加载数据bug

[所有更新日志](Changelog.md)

Expand Down
17 changes: 11 additions & 6 deletions dist/dropload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* dropload
* 西门(http://ons.me/526.html)
* 0.9.0(160215)
* 0.9.1(161205)
*/

;(function($){
Expand Down Expand Up @@ -84,12 +84,17 @@

// 窗口调整
$win.on('resize',function(){
if(me.opts.scrollArea == win){
clearTimeout(me.timer);
me.timer = setTimeout(function(){
if(me.opts.scrollArea == win){
// 重新获取win显示区高度
me._scrollWindowHeight = win.innerHeight;
}else{
me._scrollWindowHeight = me.$element.height();
}
}else{
me._scrollWindowHeight = me.$element.height();
}
fnAutoLoad(me);
},150);

});

// 绑定触摸
Expand Down Expand Up @@ -203,7 +208,7 @@

// 如果文档高度不大于窗口高度,数据较少,自动加载下方数据
function fnAutoLoad(me){
if(me.opts.autoLoad){
if(me.opts.loadDownFn != '' && me.opts.autoLoad){
if((me._scrollContentHeight - me._threshold) <= me._scrollWindowHeight){
loadDown(me);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/dropload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 27 additions & 26 deletions examples/load-top-bottom.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ <h3>12文字描述文字描述文字描述文字描述文字描述</h3>
<script src="../dist/dropload.min.js"></script>
<script>
$(function(){
var counter = 0;
// 每页展示4个
var num = 4;
var pageStart = 0,pageEnd = 0;
// 页数
var page = 0;
// 每页展示10个
var size = 10;

// dropload
$('.content').dropload({
Expand Down Expand Up @@ -249,9 +249,9 @@ <h3>12文字描述文字描述文字描述文字描述文字描述</h3>
$('.lists').html(result);
// 每次数据加载完,必须重置
me.resetload();
// 重置索引值,重新拼接more.json数据
counter = 0;
// 解锁
// 重置页数,重新获取loadDownFn的数据
page = 0;
// 解锁loadDownFn里锁定的情况
me.unlock();
me.noData(false);
},1000);
Expand All @@ -264,34 +264,35 @@ <h3>12文字描述文字描述文字描述文字描述文字描述</h3>
});
},
loadDownFn : function(me){
page++;
// 拼接HTML
var result = '';
$.ajax({
type: 'GET',
url: 'json/more.json',
url: 'http://ons.me/tools/dropload/json.php?page='+page+'&size='+size,
dataType: 'json',
success: function(data){
var result = '';
counter++;
pageEnd = num * counter;
pageStart = pageEnd - num;

for(var i = pageStart; i < pageEnd; i++){
result += '<a class="item opacity" href="'+data.lists[i].link+'">'
+'<img src="'+data.lists[i].pic+'" alt="">'
+'<h3>'+data.lists[i].title+'</h3>'
+'<span class="date">'+data.lists[i].date+'</span>'
+'</a>';
if((i + 1) >= data.lists.length){
// 锁定
me.lock();
// 无数据
me.noData();
break;
var arrLen = data.length;
if(arrLen > 0){
for(var i=0; i<arrLen; i++){
result += '<a class="item opacity" href="'+data[i].link+'">'
+'<img src="'+data[i].pic+'" alt="">'
+'<h3>'+data[i].title+'</h3>'
+'<span class="date">'+data[i].date+'</span>'
+'</a>';
}
// 如果没有数据
}else{
// 锁定
me.lock();
// 无数据
me.noData();
}
// 为了测试,延迟1秒加载
setTimeout(function(){
// 插入数据到页面,放到最后面
$('.lists').append(result);
// 每次数据加载完,必须重置
// 每次数据插入,必须重置
me.resetload();
},1000);
},
Expand Down

0 comments on commit 50d5776

Please sign in to comment.