forked from wuyawei/fe-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll.html
More file actions
49 lines (48 loc) · 1.16 KB
/
Copy pathscroll.html
File metadata and controls
49 lines (48 loc) · 1.16 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
.wrapper{
margin: 0;
padding: 0;
}
.wrapper li{
height: 100px;
background-color: red;
color: #fff;
text-align: center;
font-size: 28px;
margin-bottom: 20px;
}
</style>
<body>
<ul class="wrapper">
</ul>
</body>
<script>
const wrapper = document.querySelector('.wrapper');
let total = 100000;
let index = 0;
const page = 100;
const reFrame = () => {
if (total <= 0) return;
window.requestAnimationFrame(() => {
const fragment = document.createDocumentFragment();
new Array(page).fill('').forEach(() => {
const li = document.createElement('li');
li.innerHTML = index ++;
fragment.appendChild(li)
})
wrapper.appendChild(fragment);
total -= 100;
reFrame();
})
}
reFrame()
</script>
</html>