-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo.html
152 lines (135 loc) · 6.4 KB
/
demo.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
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<link rel="shortcut icon" href="" type="image/x-icon">
<meta content="telephone=no,email=no" name="format-detection">
<title>pull down refresh</title>
<link rel="stylesheet" href="./style.css"/>
<link rel="stylesheet" href="./nature-pull-refresh.css"/>
</head>
<body>
<div style="position: relative;height: 100px;line-height: 100px;background-color: #fff;text-align: center;font-size: 20px;z-index: 2;">这是头部</div>
<div class="pull-wrapper">
<div id="pullTop" class="pull-top">
<div id="arrowIcon" class="arrow"></div>
<div id="pullIcon" class="pointer none"></div>
<div id="succIcon" class="success none"></div>
<span id="pullText">刷新成功</span>
</div>
<div class="quan-panel has-top">
<div class="quan-panel__bd" id="list">
<div class="quan-media-box">
<div class="quan-media-box__person">
<img class="person_avator" src="./img/etc_img_free.png">
<div class="person_content">
<div class="person_content-title">下来刷新效果
<span class="person_content__tag hide author">圈主</span>
<span class="person_content__tag top">置顶</span>
<span class="person_content__tag hot">精华</span>
</div>
<div class="person_content-text">2017.10.28 11:37</div>
</div>
</div>
<div class="quan-media-box__content ellips-content">
原生js实现的下拉刷新demo
</div>
</div>
<div class="quan-media-box">
<div class="quan-media-box__person">
<img class="person_avator" src="./img/etc_img_free.png">
<div class="person_content">
<div class="person_content-title">下来刷新效果
<span class="person_content__tag hide author">圈主</span>
<span class="person_content__tag top">置顶</span>
<span class="person_content__tag hot">精华</span>
</div>
<div class="person_content-text">2017.10.28 11:37</div>
</div>
</div>
<div class="quan-media-box__content ellips-content">
原生js实现的下拉刷新demo
</div>
</div>
<div class="quan-media-box">
<div class="quan-media-box__person">
<img class="person_avator" src="./img/etc_img_free.png">
<div class="person_content">
<div class="person_content-title">下来刷新效果
<span class="person_content__tag hide author">圈主</span>
<span class="person_content__tag top">置顶</span>
<span class="person_content__tag hot">精华</span>
</div>
<div class="person_content-text">2017.10.28 11:37</div>
</div>
</div>
<div class="quan-media-box__content ellips-content">
原生js实现的下拉刷新demo
</div>
</div>
<div class="quan-media-box">
<div class="quan-media-box__person">
<img class="person_avator" src="./img/etc_img_free.png">
<div class="person_content">
<div class="person_content-title">下来刷新效果
<span class="person_content__tag hide author">圈主</span>
<span class="person_content__tag top">置顶</span>
<span class="person_content__tag hot">精华</span>
</div>
<div class="person_content-text">2017.10.28 11:37</div>
</div>
</div>
<div class="quan-media-box__content ellips-content">
原生js实现的下拉刷新demo
</div>
</div>
</div>
</div>
</div>
<script src="./nature-pull-refresh.js"></script>
<script type="text/javascript">
function getData () {
setTimeout(function() {
var str = '<div class="quan-media-box">' +
' <div class="quan-media-box__person">' +
' <img class="person_avator" src="./img/etc_img_free.png">' +
' <div class="person_content">' +
' <div class="person_content-title">下来刷新效果' +
' <span class="person_content__tag hide author">圈主</span>' +
' <span class="person_content__tag top">置顶</span>' +
' <span class="person_content__tag hot">精华</span>' +
' </div>' +
' <div class="person_content-text">2017.10.28 11:37</div>' +
' </div>' +
' </div>' +
' <div class="quan-media-box__content ellips-content">' +
' 原生js实现的下拉刷新demo' +
' </div>' +
' </div>', html = '';
for (var i = 0; i < 2; i++) {
html += str;
}
var temp = document.createElement('div');
temp.innerHTML = html;
var frag = document.createDocumentFragment();
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
document.getElementById('list').insertBefore(frag, document.getElementById('list').firstChild);
pull.emit('success');
}, 1000);
}
var pull = new pullDownRefresh({
wrapper: '.pull-wrapper'
});
pull.on('before-pull', function () {
console.log('beforePull');
});
pull.on('refresh', function () {
console.log('refresh begin');
getData();
});
</script>
</body>
</html>