-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (73 loc) · 1.97 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
<html>
<head>
<meta charset="UTF-8" />
<script src="/dist/index.js"></script>
<style>
.section-0 {
background: lightsalmon;
}
.section-1 {
background: lightblue;
}
.section-2 {
background: lightcoral;
}
.section-3 {
background: lightcyan;
}
.section-4 {
background: lightgoldenrodyellow;
}
.section-5 {
background: lightgray;
}
.section-6 {
background: lightgreen;
}
.section-7 {
background: lightpink;
}
.title {
text-align: center;
position: sticky;
top: 25px;
}
.shadow {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
</div>
</body>
<script>
for (let i = 0; i < 100; i++){
const div = document.createElement('div')
div.classList.add(`section-${i % 8}`)
div.style.cssText += 'padding: 1px'
const title = document.createElement('h1')
title.innerText = 'title'
title.classList.add('title')
div.appendChild(title)
let str = ''
for (let j = 0; j < 5; j ++){
const hello = document.createElement('p')
hello.innerText = 'hello'
div.appendChild(hello)
}
document.body.appendChild(div)
new WatchSticky(title, null, () => {title.classList.toggle('shadow', true)}, () => {title.classList.toggle('shadow', false)})
}
// const container = document.getElementById('container')
// new WatchSticky(document.getElementById('title-1'),container,() => {
// document.getElementById('title-1').classList.toggle('shadow', true)
// }, () =>{
// document.getElementById('title-1').classList.toggle('shadow', false)
// })
// new WatchSticky(document.getElementById('title-2'),container,() => {
// document.getElementById('title-2').classList.toggle('shadow', true)
// }, () =>{
// document.getElementById('title-2').classList.toggle('shadow', false)
// })
</script>
</html>