multicontainer_multilist.html
4.64 KB
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
<!--
作者:dailc
时间:2017-08-29
描述: 多个容器,多个列表
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>multicontainer multilist</title>
<link rel="stylesheet" href="../../dist/debug/minirefresh.css" />
<link rel="stylesheet" href="../common/common.css" />
<style>
.minirefresh-wrap {
top: 90px;
}
.navbar-header {
border: none;
}
</style>
</head>
<body>
<nav class="navbar-header">
<a class="nav-btn-left" href="../index.html">dashboard</a>
多个Minirefresh
</nav>
<div class="content">
<div class="nav-control">
<p class="active" list-type="0">列表0</p>
<p list-type="1">列表1</p>
<p list-type="2">列表2</p>
</div>
<div id="minirefresh0" class="minirefresh-wrap">
<div class="minirefresh-scroll">
<ul class="data-list" id="listdata0">
</ul>
</div>
</div>
<div id="minirefresh1" class="minirefresh-wrap minirefresh-hidden">
<div class="minirefresh-scroll">
<ul class="data-list" id="listdata1">
</ul>
</div>
</div>
<div id="minirefresh2" class="minirefresh-wrap minirefresh-hidden">
<div class="minirefresh-scroll">
<ul class="data-list" id="listdata2">
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="../../dist/debug/minirefresh.js"></script>
<script type="text/javascript" src="../common/common.js"></script>
<script>
var appendTestData = Common.appendTestData,
bindEvent = Common.bindEvent,
// 记录一个最新
maxDataSize = 30,
listDomArr = [],
requestDelayTime = 600,
currIndex = 0,
miniRefreshArr = [];
var initMiniRefreshs = function(index) {
listDomArr[index] = document.querySelector('#listdata' + index);
miniRefreshArr[index] = new MiniRefresh({
container: '#minirefresh' + index,
down: {
callback: function() {
setTimeout(function() {
// 每次下拉刷新后,上拉的状态会被自动重置
appendTestData(listDomArr[index], 10, true, index);
miniRefreshArr[index].endDownLoading(true);
}, requestDelayTime);
}
},
up: {
isAuto: true,
callback: function() {
setTimeout(function() {
appendTestData(listDomArr[index], 10, false, index);
miniRefreshArr[index].endUpLoading(listDomArr[index].children.length >= maxDataSize ? true : false);
}, requestDelayTime);
}
}
});
};
var navControl = document.querySelector('.nav-control'),
CLASS_HIDDEN = 'minirefresh-hidden';
bindEvent('.nav-control p', function(e) {
var type = this.getAttribute('list-type');
type = +type;
if (type !== currIndex) {
navControl.querySelector('.active').classList.remove('active');
this.classList.add('active');
document.querySelector('#minirefresh' + currIndex).classList.add(CLASS_HIDDEN);
document.querySelector('#minirefresh' + type).classList.remove(CLASS_HIDDEN);
currIndex = type;
if (!miniRefreshArr[currIndex]) {
initMiniRefreshs(currIndex);
}
}
}, 'click');
// 初始化
initMiniRefreshs(0);
</script>
</body>
</html>