-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
270 lines (231 loc) · 7.18 KB
/
index.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>pulldownRefresh2</title>
<style>
/**{*/
/*margin: 0;*/
/*padding: 0;*/
/*}*/
.pulldownRefresh{
}
.pulldownRefresh-container{
}
.pulldownRefresh-caption{
display: none;
text-align: center;
}
.icon {
/* 通过设置 font-size 来改变图标大小 */
width: 1em; height: 1em;
/* 图标和文字相邻时,垂直对齐 */
vertical-align: -0.15em;
/* 通过设置 color 来改变 SVG 的颜色/fill */
fill: currentColor;
/* path 和 stroke 溢出 viewBox 部分在 IE 下会显示
normalize.css 中也包含这行 */
overflow: hidden;
}
.pulldownRefresh-caption-icon{
font-size: 18px;
}
.pulldownRefresh-caption-icon-spinner{
display: none;
-webkit-transition: -webkit-transform 0.3s ease-in;
-webkit-transform: rotate(180deg);
-webkit-animation: spinner-spin 1s step-end infinite;
transition: -webkit-transform 0.3s ease-in;
transform: rotate(180deg);
animation: spinner-spin 1s step-end infinite;
}
@-webkit-keyframes spinner-spin
{
0%
{
-webkit-transform: rotate(0deg);
}
8.33333333%
{
-webkit-transform: rotate(30deg);
}
16.66666667%
{
-webkit-transform: rotate(60deg);
}
25%
{
-webkit-transform: rotate(90deg);
}
33.33333333%
{
-webkit-transform: rotate(120deg);
}
41.66666667%
{
-webkit-transform: rotate(150deg);
}
50%
{
-webkit-transform: rotate(180deg);
}
58.33333333%
{
-webkit-transform: rotate(210deg);
}
66.66666667%
{
-webkit-transform: rotate(240deg);
}
75%
{
-webkit-transform: rotate(270deg);
}
83.33333333%
{
-webkit-transform: rotate(300deg);
}
91.66666667%
{
-webkit-transform: rotate(330deg);
}
100%
{
-webkit-transform: rotate(360deg);
}
}
@keyframes spinner-spin
{
0%
{
transform: rotate(0deg);
}
8.33333333%
{
transform: rotate(30deg);
}
16.66666667%
{
transform: rotate(60deg);
}
25%
{
transform: rotate(90deg);
}
33.33333333%
{
transform: rotate(120deg);
}
41.66666667%
{
transform: rotate(150deg);
}
50%
{
transform: rotate(180deg);
}
58.33333333%
{
transform: rotate(210deg);
}
66.66666667%
{
transform: rotate(240deg);
}
75%
{
transform: rotate(270deg);
}
83.33333333%
{
transform: rotate(300deg);
}
91.66666667%
{
transform: rotate(330deg);
}
100%
{
transform: rotate(360deg);
}
}
</style>
<script src="iconfont.js"></script>
</head>
<body>
<div class="pulldownRefresh" id="pulldownRefresh">
<div class="pulldownRefresh-caption pulldownRefresh-pulldown-caption" id="pulldownRefresh-pulldown-caption">
<svg class="icon pulldownRefresh-caption-icon" id="pulldownRefresh-pulldown-caption-icon-pulldown" aria-hidden="true">
<use xlink:href="#icon-pulldown"></use>
</svg>
<svg class="icon pulldownRefresh-caption-icon pulldownRefresh-caption-icon-spinner" id="pulldownRefresh-pulldown-caption-icon-spinner" aria-hidden="true">
<use xlink:href="#icon-spinner"></use>
</svg>
<i class="pulldownRefresh-pulldown-caption-text" id="pulldownRefresh-pulldown-caption-text"></i>
</div>
<div class="pulldownRefresh-container" id="pulldownRefresh-container">
<ul id="list">
<li>list 1</li>
<li>list 2</li>
<li>list 3</li>
<li>list 4</li>
<li>list 5</li>
</ul>
</div>
<div class="pulldownRefresh-caption pulldownRefresh-pullup-caption" id="pulldownRefresh-pullup-caption">
<svg class="icon pulldownRefresh-caption-icon pulldownRefresh-caption-icon-spinner" id="pulldownRefresh-pullup-caption-icon-spinner" aria-hidden="true">
<use xlink:href="#icon-spinner"></use>
</svg>
<i class="pulldownRefresh-pullup-caption-text" id="pulldownRefresh-pullup-caption-text"></i>
</div>
</div>
<script src="pulldownRefresh.js"></script>
<script>
var loadTime=0;
pulldownRefresh.init({
down:{
length:50,
damping:5,
contentdown:'下拉可以刷新',
contentover:'释放立即刷新',
contentrefresh:'正在刷新...',
callback:function () {
setTimeout(function () {
var li=document.createElement('LI');
li.appendChild(document.createTextNode("这是新段落"+Math.random()*10));
document.getElementById('list').appendChild(li);
pulldownRefresh.endPulldownToRefresh();
pulldownRefresh.refresh();
loadTime=0;
},2000);
}
},
up:{
length:50,
damping:2,
contentup:'上拉显示更多',
contentnomore:'没有更多数据了',
contentrefresh:'正在刷新...',
callback:function () {
loadTime++;
var li=document.createElement('LI');
li.appendChild(document.createTextNode("这是新段落"+Math.random()*10));
setTimeout(function () {
document.getElementById('list').appendChild(li);
if(loadTime==1){
pulldownRefresh.endPullupToRefresh(true);
}else if(loadTime==2){
console.log('ajax error!');
pulldownRefresh.hidePullupCaption();
}else{
pulldownRefresh.endPullupToRefresh();
}
},2000);
}
}
});
pulldownRefresh.showPullupCaption();
</script>
</body>
</html>