-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.js
75 lines (64 loc) · 1.72 KB
/
loader.js
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
document.addEventListener('DOMContentLoaded', function () {
const loaderOverlay = document.createElement('div');
loaderOverlay.classList.add('loader-overlay');
const loader = document.createElement('div');
loader.classList.add('loader');
for (let i = 0; i < 4; i++) {
const loaderBar = document.createElement('div');
loader.appendChild(loaderBar);
}
loaderOverlay.appendChild(loader);
document.body.appendChild(loaderOverlay);
const style = document.createElement('style');
style.innerHTML = `
.loader-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgb(0, 0, 0);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.loader {
display: flex;
justify-content: center;
width: 120px;
height: 50px;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.loader div {
width: 12px;
height: 100%;
margin: 0 4px;
background-color: rgb(238, 130, 130);
box-shadow: 0 0 10px rgba(123, 72, 243, 0.5);
animation: bar-animation 1.5s ease-out infinite;
z-index: 1000;
}
@keyframes bar-animation {
0% {
height: 100%;
background-color: rgb(238, 130, 130);
}
50% {
height:-150%;
background-color: white;
}
100% {
height: 100%;
background-color: rgb(238, 130, 130);
}
}
`;
document.head.appendChild(style);
window.onload = function() {
setTimeout(() => {
loaderOverlay.style.display = 'none';
}, 2000);
};
});