-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (47 loc) · 985 Bytes
/
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
<html><head><style>
#container {
overflow: scroll;
height: 400px;
width: 400px;
background-color:green;
scroll-snap-type: y mandatory;
position: absolute;
}
#area1 {
background-color: blue;
position: absolute;
top: 2000px;
left:0px;
width: 100px;
height: 100px;
scroll-snap-align: start;
}
#area2 {
background-color: green;
position: absolute;
top: 5000px;
left:0px;
width: 100px;
height: 100px;
scroll-snap-align: start;
}
.space {
height: 10000px;
width: 400px;
}</style>
<script>
var did_scroll = false;
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('scroll', () => {
if (document.scrollingElement.scrollTop > 1950 && !did_scroll) {
document.scrollingElement.scrollTo(0, 5000);
did_scroll = true;
}
});
});
</script>
</head><body>
<div id="container"><div class="space"></div><div id="area1"><h2>1</h2></div>
<div id="area2"><h2>2</h2></div>
</div>
</body></html>