250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- front-end
- image
- css3
- button
- 풀스택
- effect
- php
- Animation
- ipad
- 애니메이션
- iPhone
- hover
- javascript
- MAC
- 비전공 개발자
- 개발자
- 자바스크립트
- html5
- CSS
- jQuery
- 비전공자
- xcode
- IOS
- 백엔드
- iOS 개발자
- keyframes
- react
- HTML
- SWIFT
- 프론트엔드
Archives
- Today
- Total
비전공자 개발일기
Javascript - Blurry Loading 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<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">
<title>Blurry Loading</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<section class="bg"></section>
<div class="loading-text">0%</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Ubuntu');
* {
box-sizing: border-box;
}
body {
font-family: 'Ubuntu', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
.bg {
background: url('./1.jpg') no-repeat center center/cover;
position: absolute;
top: -30;
left: -30;
width: calc(100vw + 60px);
height: calc(100vh + 60px);
z-index: -1;
filter: blur(30px);
}
.loading-text {
font-size: 50px;
color: #000;
}
const loadText = document.querySelector(".loading-text");
const 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)`
}
// https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers
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
}
728x90
LIST
'Javascript' 카테고리의 다른 글
Javascript - Expanding Cards (0) | 2021.09.25 |
---|---|
Javascript - Vertical Slider (0) | 2021.09.24 |
Javascript - Dynamic Banner (0) | 2021.09.22 |
Javascript - 3D Page (0) | 2021.09.21 |
Javascript - Calculator (0) | 2021.09.19 |