-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (62 loc) · 1.81 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pure Infinite Scroll Example</title>
<style>
#wrapper {
width: 500px;
height: 400px;
overflow-y: auto;
background: gray;
border-radius: 20px;
}
#content {
padding: 20px;
box-sizing: border-box;
}
.child {
width: 100%;
height: 50px;
background: blue;
border-radius: 20px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="content">
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
<div class="child"></div>
</div>
</div>
</body>
<script src="../dist/pure-infinite-scroll.umd.cjs"></script>
<script>
const wrapper = document.getElementById('wrapper');
const content = document.getElementById('content');
const infiniteScroll = new PureInfiniteScroll(wrapper, content);
infiniteScroll.on('scrolledBottom', () => {
for (let i = 0; i < 8; i++) {
const newChild = document.createElement('div');
newChild.className = 'child';
content.appendChild(newChild);
}
});
infiniteScroll.on('scrolledTop', () => {
for (let i = 0; i < 8; i++) {
const newChild = document.createElement('div');
newChild.className = 'child';
content.insertBefore(newChild, content.firstChild);
}
});
</script>
</html>