Skip to content

Commit

Permalink
completed blurry load
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jun 29, 2021
1 parent 09de275 commit b77ba13
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Day 5 - Blurry Loading/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./style.css" />
<title>Blurry | Loading</title>
</head>
<body>
<section class="bg"></section>
<div class="loading-text">0%</div>

<script src="./script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions Day 5 - Blurry Loading/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Block element and variables
const loadText = document.querySelector(".loading-text");
const bg = document.querySelector(".bg");

let load = 0;

let int = setInterval(blurring, 30);

// function
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)`;
}

//https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers?answertab=votes#tab-top

const scale = (number, inMin, inMax, outMin, outMax) => {
return ((number - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
};
37 changes: 37 additions & 0 deletions Day 5 - Blurry Loading/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@import url("https://fonts.googleapis.com/css?family=Ubuntu");

*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
font-family: "Ubuntu", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

.bg {
background: url("https://images.unsplash.com/photo-1474044159687-1ee9f3a51722?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80")
no-repeat center center/cover;
position: relative;
top: -30px;
left: -30px;
width: calc(100vw + 60px);
height: calc(100vh + 60px);
z-index: -1;
filter: blur(0px);
}

.loading-text {
position: relative;
font-size: 50px;
color: #fff;
left: -650px;
}

0 comments on commit b77ba13

Please sign in to comment.