-
Notifications
You must be signed in to change notification settings - Fork 1
/
loader.html
99 lines (96 loc) · 1.92 KB
/
loader.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Loader</title>
<style>
:root{
--loader-bar-width: 0%;
}
body, html {
margin: 0;
padding: 0;
}
.loader-container {
display: flex;
background-color: black;
position: absolute;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
left: 0;
top: 0;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
}
#loaderLoadingBar {
width: 788px;
height: 38px;
color: white;
background-color: white;
position: relative;
left: 6px;
top: 6px;
transform: scale(var(--loader-bar-width),100%);
transform-origin: left center;
}
#loaderBorder {
border: 4px solid white;
min-width: 800px;
max-width: 800px;
min-height: 50px;
max-height: 50px;
}
.fade {
animation: fade 3s ease-out forwards;
}
@keyframes fade {
0% {
transform: scale(1);
opacity: 1;
}
99.999% {
transform: scale(4);
opacity: 0;
}
100% {
transform: scale(0);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="loader-container">
<div id="loaderBorder">
<div id="loaderLoadingBar"></div>
</div>
</div>
</body>
<script>
var x = document.querySelector(":root");
var width = 0;
var loaded = false;
function loaderUpdate(){
var xy = getComputedStyle(x);
x.style.setProperty("--loader-bar-width", width+"%");
if (loaded === true){
console.log("Loaded");
clearInterval(xm);
document.getElementById("loaderBorder").classList.add("fade");
}
}
var xm = setInterval(() => {
loaderUpdate();
if (width < 100){
width += 1;
}
else if (width >= 100) {
loaded = true;
}
}, 125);
</script>
</html>