-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlazyloadingimg.html
More file actions
89 lines (72 loc) · 2.13 KB
/
lazyloadingimg.html
File metadata and controls
89 lines (72 loc) · 2.13 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
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.wrapper {
display: flex;
justify-content: flex-start;
align-items: center;
overflow: hidden;
height: 100vh;
}
.bg {
background: url(images/green-gallary/drops-green.jpg) no-repeat center center/cover;
position: absolute;
top: 20px;
left: 30px;
width: calc(50vw - 60px);
/* height: calc(50vh - 60px); */
aspect-ratio: 12/9;
z-index: -1;
filter: blur(0);
}
/* .loading-text {
font-size: 2rem;
color: black;
} */
.space {
display: flex;
justify-content: center;
align-items: center;
background: #000;
color: white;
height: 100vh;
}
</style>
</head>
<body>
<div class="wrapper">
<section class="bg"></section>
<!-- <div class="loading-text">0%</div> -->
</div>
<div class="space">
<h1>heeee</h1>
</div>
<script>
//let loadText = document.querySelector(".loading-text");
let bg = document.querySelector(".bg");
let load = 0;
let int = setInterval(blurring, 30);
function blurring() {
load++;
if (load > 99) {
clearInterval(int);
}
//loadText.innerText = `${load}%`;
//loadText.style.opacity = scale(load, 0, 100, 1, 0);
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
}
const scale = (num, in_min, in_max, out_min, out_max) => {
return ((num - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
};
</script>
</body>
</html>