-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex2.html
92 lines (92 loc) · 3.18 KB
/
index2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>pullload 支持 require.js 方式</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<script src="js/require.js"></script>
<script src="js/require-config.js"></script>
<style>
html,body{ margin: 0; padding: 0;}
li{font-size: 20px; width: 100%;list-style: none;}
img{width: 100%;}
div, .test-ul, p{margin: 0; padding: 0;}
</style>
<link rel="stylesheet" href="css/pullload.less">
</head>
<body>
<div id="test_div" class="">
<div class="tloader-symbol">
<p class="tloader-msg"><i></i></p>
<p class="tloader-loading">
<i class="ui-loading"></i>
</p>
</div>
<div class="tloader-body">
<ul class="test-ul">
</ul>
</div>
<div class="tloader-footer">
<p class="tloader-btn"></p>
<p class="tloader-loading">
<i class="ui-loading"></i>
</p>
</div>
</div>
<script>
require(["zepto", "pullload"], function($, pullload) {
var loadMoreIndex = 3;
var data = [
"http://img1.gtimg.com/15/1580/158031/15803178_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803179_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803181_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803182_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803183_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803184_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803186_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803187_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803189_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803190_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803191_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803193_1200x1000_0.jpg",
"http://img1.gtimg.com/15/1580/158031/15803194_1200x1000_0.jpg",
]
function createLi(src){
return '<li><img src="' + src + '" alt=""></li>'
}
function createAll(arr){
var index = 0, len = arr.length, html = "";
for(index; index < len; index++){
html += createLi(arr[index]);
}
return html;
}
$(".test-ul").html(createAll(data));
var installObj = new pullload({
container: document.body,
wrapper: document.getElementById("test_div"),
downEnough: 100,
onRefresh: function(success,error){
console.info("实际代码 onRefresh")
setTimeout(function(){
$(".test-ul").html(createAll(data));
success();
},2000);
},
onLoadMore: function(success, error){
console.info("实际代码 onLoadMore")
setTimeout(function(){
$(".test-ul").append(createLi(data[loadMoreIndex]));
if(--loadMoreIndex){
success(false);
} else{
success(true);
}
},2000);
},
distanceBottom: 150,
});
});
</script>
</body>
</html>