-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnew_file.html
333 lines (300 loc) · 8 KB
/
new_file.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>单页面多个下拉刷新实现</title>
<script src="js/swiper-3.4.1.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="css/swiper-3.4.1.css" />
<script src="js/swiper_pullRefresh.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="css/swiper_pullRefresh.css" /> </head>
<style type="text/css">
html,
body {
height: 100%;
background-color: #eee;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
margin: 0;
padding: 0;
}
li {
list-style: none;
}
#tab {
height: 100%;
/*border: 5px solid yellow;*/
padding-top: 50px;
}
#tab .swiper-pagination {
/*width: 100%;*/
height: 50px;
line-height: 45px;
top: 0;
display: flex;
/*color: red;*/
border-bottom: 1px solid;
}
#tab .swiper-pagination > .swiper-pagination-bullet {
width: calc(100% / 3);
border-radius: initial;
height: initial;
opacity: initial;
background-color: initial;
margin: 0;
}
#tab .swiper-pagination > .swiper-pagination-bullet-active {
background-color: salmon;
color: white;
}
#tab1,
#tab2,
#tab3_1,
#tab3_2 {
height: 100%;
width: 100%;
/*background-color: #eee;*/
}
.swiper-slide.flex {
display: flex;
}
.swiper-pullRefresh-body {
background-color: #fff;
}
.swiper-slide {
background-color: #eee;
}
</style>
<body>
<div class="swiper-container" id="tab">
<div class="swiper-pagination"></div>
<div class="swiper-wrapper">
<div class="swiper-slide" data-hash="slide1">
<div class="swiper-container swiper-pullRefresh" id="tab1">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-pullRefresh-body">
<!--body-->
</div>
</div>
</div>
<!--进度条-->
<div class="swiper-scrollbar"></div>
</div>
</div>
<div class="swiper-slide" data-hash="slide2">
<div class="swiper-container swiper-pullRefresh" id="tab2">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-pullRefresh-body">
<!--body-->
</div>
</div>
</div>
<!--进度条-->
<div class="swiper-scrollbar"></div>
</div>
</div>
<div class="swiper-slide flex" data-hash="slide3">
<div class="swiper-container swiper-pullRefresh" id="tab3_1">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-pullRefresh-body">
<!--body-->
</div>
</div>
</div>
<!--进度条-->
<div class="swiper-scrollbar"></div>
</div>
<div class="swiper-container swiper-pullRefresh" id="tab3_2">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-pullRefresh-body">
<!--body-->
</div>
</div>
</div>
<!--进度条-->
<div class="swiper-scrollbar"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var tabBodySwiper = new Swiper('#tab', {
effect: 'coverflow',
coverflow: {
rotate: 10,
},
hashnav: true,
hashnavWatchState:true,
direction: 'horizontal', //Slides的滑动方向,可设置水平(horizontal)或垂直(vertical)。
// autoHeight: true, //自动高度。设置为true时,wrapper和container会随着当前slide的高度而发生变化。
pagination: '.swiper-pagination',
paginationClickable: true,
paginationBulletRender: function(swiper, index, className) {
return '<div class="' + className + '">' + 'tab' + (index + 1) + '</div>';
},
});
{ //tab1
var data1 = function() {
var i = 0;
return {
next: function() {
if((i++) < 3) {
var text = '';
for(var i1 = 0; i1 < 200; i1++) {
for(var i2 = 0; i2 < Math.random() * 10 + 3; i2++) {
text += String.fromCharCode(97 + Math.ceil(Math.random() * 25));
};
text += ' ';
};
return {
value: text,
};
} else {
return {
done: true,
};
};
},
};
};
var getdata1 = data1(); //迭代器
var tab1Swiper = SwiperRefresh('#tab1', {
scrollbar: '.swiper-scrollbar', //进度条
down: {
auto: false,
callback: function(swiper) {
console.log('触发刷新');
setTimeout(function(swiper) { //延时模拟异步
getdata1 = data1(); //重置迭代器
var thisData1 = getdata1.next();
swiper.slides.find('.swiper-pullRefresh-body').html(thisData1.value + '');
swiper.endPulldownToRefresh();
swiper.refresh();
}, 1000, swiper);
},
},
up: {
auto: true,
callback: function(swiper) {
console.log('触发加载');
setTimeout(function(swiper) { //延时模拟异步
var thisData1 = getdata1.next();
swiper.slides.find('.swiper-pullRefresh-body').append(thisData1.value + '');
swiper.endPullupToRefresh(thisData1.done);
}, 1000, swiper);
},
},
});
}
{ //tab2
var data2 = function() {
var i = 0;
return {
next: function() {
if(i < 100) {
var text = '';
for(var i1 = 0; i1 < 10; i1++) {
text += '<div>' + i++ + '</div>';
};
return {
value: text,
};
} else {
return {
done: true,
};
};
},
};
};
var getdata2 = data2(); //迭代器
var tab2Swiper = SwiperRefresh('#tab2', {
scrollbar: '.swiper-scrollbar', //进度条
down: {
auto: false,
callback: function(swiper) {
console.log('触发刷新');
setTimeout(function(swiper) { //延时模拟异步
getdata2 = data2(); //重置迭代器
var thisData2 = getdata2.next();
swiper.slides.find('.swiper-pullRefresh-body').html(thisData2.value + '');
swiper.endPulldownToRefresh();
swiper.refresh();
}, 1000, swiper);
},
},
up: {
auto: true,
callback: function(swiper) {
console.log('触发加载');
setTimeout(function(swiper) { //延时模拟异步
var thisData2 = getdata2.next();
swiper.slides.find('.swiper-pullRefresh-body').append(thisData2.value + '');
swiper.endPullupToRefresh(thisData2.done);
}, 1000, swiper);
},
},
});
}
{ //tab3
var data3 = function() {
var i = 0;
return {
next: function() {
if((i++) < 100) {
return {
value: '<div>' + new Date().toJSON() + '</div>',
};
} else {
return {
done: true,
};
};
},
};
};
var getdata3 = data3(); //迭代器
tab3Pz = {
scrollbar: '.swiper-scrollbar', //进度条
down: {
auto: false,
callback: function(swiper) {
console.log('触发刷新');
setTimeout(function(swiper) { //延时模拟异步
getdata3 = data3(); //重置迭代器
var thisData3 = getdata3.next();
swiper.slides.find('.swiper-pullRefresh-body').html(thisData3.value + '');
swiper.endPulldownToRefresh();
swiper.refresh();
}, 1000, swiper);
},
},
up: {
auto: true,
callback: function(swiper) {
console.log('触发加载');
setTimeout(function(swiper) { //延时模拟异步
var thisData3 = getdata3.next();
swiper.slides.find('.swiper-pullRefresh-body').append(thisData3.value + '');
swiper.endPullupToRefresh(thisData3.done);
}, 1000, swiper);
},
},
}
var tab3_1Swiper = SwiperRefresh('#tab3_1', tab3Pz);
var tab3_2Swiper = SwiperRefresh('#tab3_2', tab3Pz);
}
console.log(123);
</script>
</body>
</html>