Skip to content

Commit 050f6fa

Browse files
committed
Blurry Loading Mini project
1 parent 2e9b1fd commit 050f6fa

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

103-Blurry Loading/img/one.jpg

1.67 MB
Loading

103-Blurry Loading/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="style.css">
7+
<title>Blurry Loading</title>
8+
</head>
9+
<body>
10+
<section class="bg"></section>
11+
<div class="loading-text">0%</div>
12+
13+
<script src="script.js"></script>
14+
</body>
15+
</html>

103-Blurry Loading/script.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let loadingText = document.querySelector('.loading-text');
2+
let bg = document.querySelector('.bg');
3+
4+
5+
let load = 0;
6+
let int = setInterval(doIt, 50)
7+
8+
function doIt() {
9+
load++;
10+
loadingText.innerHTML = `${load}%`;
11+
12+
if (load === 100) {
13+
clearInterval(int)
14+
}
15+
loadingText.style.opacity = scale(load, 0, 100, 1, 0)
16+
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`
17+
}
18+
19+
let scale = (num, in_min, in_max, out_min, out_max) =>{
20+
21+
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
22+
}
23+
24+

103-Blurry Loading/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@import url('https://fonts.googleapis.com/css?family=Ubuntu&display=swap');
2+
3+
4+
body{
5+
display: flex;
6+
justify-content: center;
7+
align-items: center;
8+
height: 100vh;
9+
font-family: Ubuntu;
10+
margin: 0;
11+
overflow: hidden;
12+
}
13+
14+
.bg{
15+
background: url(img/one.jpg) no-repeat center center/cover;
16+
width: calc(100vw + 60px);
17+
height: calc(100vw + 60PX);
18+
position: absolute;
19+
top: -30px;
20+
left: -30px;
21+
z-index: -1;
22+
}
23+
24+
.loading-text{
25+
font-size: 70px;
26+
color: white;
27+
}

0 commit comments

Comments
 (0)