-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpixel-loading.html
More file actions
80 lines (80 loc) · 2.29 KB
/
Copy pathpixel-loading.html
File metadata and controls
80 lines (80 loc) · 2.29 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
* {
margin: 0;
padding: 0;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, 2rem);
grid-template-rows: repeat(4, 2rem);
padding: 0.125rem;
width: fit-content;
margin: 2rem auto;
}
.box {
background-color: #fff;
}
.fill {
transition: background-color 0.5s ease;
}
.fill.black {
background-color: #000;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="box box-1"></div>
<div class="box box-2 fill" data-order="1"></div>
<div class="box box-3 fill" data-order="2"></div>
<div class="box box-4"></div>
<div class="box box-5 fill" data-order="8"></div>
<div class="box box-6"></div>
<div class="box box-7"></div>
<div class="box box-8 fill" data-order="3"></div>
<div class="box box-9 fill" data-order="7"></div>
<div class="box box-10"></div>
<div class="box box-11"></div>
<div class="box box-12 fill" data-order="4"></div>
<div class="box box-13"></div>
<div class="box box-14 fill" data-order="6"></div>
<div class="box box-15 fill" data-order="5"></div>
<div class="box box-16"></div>
</div>
<script>
const fills = []
for (let num = 1; num <= 8; num++) {
const element = document.querySelector(`[data-order="${num}"]`)
if (element) {
fills.push(element)
}
}
const delayBetweenElements = 200
const activeDuration = 400
const intervalDuration = 1600
fills.forEach((el, i) => {
setTimeout(() => {
el.classList.add('black')
setTimeout(() => {
el.classList.remove('black')
}, activeDuration)
}, delayBetweenElements * i)
})
setInterval(() => {
fills.forEach((el, i) => {
setTimeout(() => {
el.classList.add('black')
setTimeout(() => {
el.classList.remove('black')
}, activeDuration)
}, delayBetweenElements * i)
})
}, intervalDuration)
</script>
</body>
</html>