-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinfinityPage.html
More file actions
58 lines (45 loc) · 1.34 KB
/
infinityPage.html
File metadata and controls
58 lines (45 loc) · 1.34 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
padding: 20px;
}
#arrowTop {
height: 9px;
width: 14px;
color: green;
position: fixed;
top: 10px;
left: 10px;
cursor: pointer;
}
#arrowTop::before {
content: '▲';
}
</style>
</head>
<body>
<div id="arrowTop"></div>
<h1>Прокрути меня</h1>
<script>
arrowTop.onclick = function () {
window.scrollTo(pageXOffset, 0);
};
window.addEventListener('scroll', function () {
console.log(`${pageYOffset} + ${document.documentElement.clientHeight}`)
arrowTop.hidden = pageYOffset < document.documentElement.clientHeight;
});
function populate() {
while (true) {
let windowRelativeBottom = document.documentElement.getBoundingClientRect().bottom;
if (windowRelativeBottom > document.documentElement.clientHeight + 100) break;
document.body.insertAdjacentHTML("beforeend", `<p>Date: ${new Date()}</p>`);
}
}
window.addEventListener('scroll', populate);
populate(); // инициализация документа
</script>
</body>
</html>