-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.html
106 lines (94 loc) · 2.5 KB
/
example.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no,initial-scale=1.0">
<link rel="stylesheet" href="lib/infinite-scroll.css">
<style>
section {
display: inline-block;
}
#demo1 {
height: 400px;
width: 300px;
margin-right: 20px;
background-color: yellow;
}
#demo2 {
height: 500px;
width: 200px;
background-color: red;
}
ol {
width: 100%;
margin: 0;
padding: 0;
}
li {
height: 100px;
line-height: 100px;
vertical-align: middle;
width: 100%;
border-bottom: 1px solid #000;
}
</style>
</head>
<body>
<section id="demo1">
<ol>
<li>Total 60 items / 6 step</li>
<li>With spinner</li>
<li>500ms to load more items</li>
<li>Record 4</li>
<li>Record 5</li>
<li>Record 6</li>
</ol>
</section>
<section id="demo2">
<ol>
<li>Total 160 items / 8 step</li>
<li>Without spinner</li>
<li>200ms to load more items</li>
<li>Record 4</li>
<li>Record 5</li>
<li>Record 6</li>
<li>Record 7</li>
<li>Record 8</li>
</ol>
</section>
<script src="lib/infinite-scroll.js"></script>
<script>
var olElem1 = document.querySelector('#demo1 ol');
InfiniteScroll.create ({
element: '#demo1',
callback: function load(done) {
setTimeout(function() {
var num = olElem1.getElementsByTagName('li').length + 1;
for(var i = 0; i < 6; i++) {
var li = document.createElement('li');
li.textContent = 'Record ' + num++;
olElem1.appendChild(li);
}
done((num >= 60) ? true : false);
}, 500);
}
});
var olElem2 = document.querySelector('#demo2 ol');
InfiniteScroll.create ({
element: '#demo2',
spinner: false,
callback: function load(done) {
setTimeout(function() {
var num = olElem2.getElementsByTagName('li').length + 1;
for(var i = 0; i < 8; i++) {
var li = document.createElement('li');
li.textContent = 'Record ' + num++;
olElem2.appendChild(li);
}
done((num >= 160) ? true : false);
}, 200);
}
});
</script>
</body>
</html>