Skip to content

Commit 7d2139d

Browse files
committed
blurry loading and vertical slider projects
1 parent 3c56991 commit 7d2139d

6 files changed

Lines changed: 247 additions & 0 deletions

File tree

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 http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="style.css" />
8+
<title>Blurry Loading</title>
9+
</head>
10+
<body>
11+
<section class="bg"></section>
12+
<div class="loading-text">0%</div>
13+
<script src="script.js"></script>
14+
</body>
15+
</html>

blurry-loading/script.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const loadText = document.querySelector('.loading-text')
2+
const bg = document.querySelector('.bg')
3+
4+
let load = 0
5+
let int = setInterval(blurring, 30)
6+
7+
function blurring() {
8+
load++
9+
10+
if(load > 99) {
11+
clearInterval(int)
12+
}
13+
14+
loadText.innerText = `${load}%`
15+
loadText.style.opacity = scale(load, 0, 100, 1, 0)
16+
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`
17+
18+
}
19+
20+
// https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers
21+
const scale = (num, in_min, in_max, out_min, out_max) => {
22+
return ((num - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min }

blurry-loading/style.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@import url('https://fonts.googleapis.com/css?family=Ubuntu');
2+
3+
* {
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
font-family: 'Ubuntu', sans-serif;
9+
display: flex;
10+
align-items: center;
11+
justify-content: center;
12+
height: 100vh;
13+
overflow: hidden;
14+
margin: 0;
15+
}
16+
17+
.bg {
18+
background: url('https://images.unsplash.com/photo-1576161787924-01bb08dad4a4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2104&q=80')
19+
no-repeat center center/cover;
20+
position: absolute;
21+
top: -30px;
22+
left: -30px;
23+
width: calc(100vw + 60px);
24+
height: calc(100vh + 60px);
25+
z-index: -1;
26+
filter: blur(0px);
27+
}
28+
29+
.loading-text {
30+
font-size: 50px;
31+
color: #fff;
32+
}

vertical-slider/index.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" />
8+
<link rel="stylesheet" href="style.css" />
9+
<title>Vertical Slider</title>
10+
</head>
11+
<body>
12+
<div class="slider-container">
13+
<div class="left-slide">
14+
<div style="background-color: #FD3555;">
15+
<h1>Nature flower</h1>
16+
<p>all in pink</p>
17+
</div>
18+
<div style="background-color: #2A86BA;">
19+
<h1>Blue Sky</h1>
20+
<p>with it's mountains</p>
21+
</div>
22+
<div style="background-color: #252E33;">
23+
<h1>Lonely Castle</h1>
24+
<p>in the wilderness</p>
25+
</div>
26+
<div style="background-color: #FFB866;">
27+
<h1>Flying Eagle</h1>
28+
<p>in the sunset</p>
29+
</div>
30+
</div>
31+
<div class="right-slide">
32+
<div style="background-image: url('https://images.unsplash.com/photo-1508768787810-6adc1f613514?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e27f6661df21ed17ab5355b28af8df4e&auto=format&fit=crop&w=1350&q=80')"></div>
33+
<div style="background-image: url('https://images.unsplash.com/photo-1519981593452-666cf05569a9?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=90ed8055f06493290dad8da9584a13f7&auto=format&fit=crop&w=715&q=80')"></div>
34+
<div style="background-image: url('https://images.unsplash.com/photo-1486899430790-61dbf6f6d98b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=8ecdee5d1b3ed78ff16053b0227874a2&auto=format&fit=crop&w=1002&q=80')"></div>
35+
<div style="background-image: url('https://images.unsplash.com/photo-1510942201312-84e7962f6dbb?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=da4ca7a78004349f1b63f257e50e4360&auto=format&fit=crop&w=1050&q=80')"></div>
36+
</div>
37+
<div class="action-buttons">
38+
<button class="down-button">
39+
<i class="fas fa-arrow-down"></i>
40+
</button>
41+
<button class="up-button">
42+
<i class="fas fa-arrow-up"></i>
43+
</button>
44+
</div>
45+
</div>
46+
<script src="script.js"></script>
47+
</body>
48+
</html>

vertical-slider/script.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const sliderContainer = document.querySelector('.slider-container')
2+
const slideRight = document.querySelector('.right-slide')
3+
const slideLeft = document.querySelector('.left-slide')
4+
const upButton = document.querySelector('.up-button')
5+
const downButton = document.querySelector('.down-button')
6+
const slidesLength = slideRight.querySelectorAll('div').length
7+
8+
let activeSlideIndex = 0
9+
10+
slideLeft.style.top = `-${(slidesLength - 1) * 100}vh`
11+
12+
upButton.addEventListener('click', () => changeSlide('up'))
13+
downButton.addEventListener('click', () => changeSlide('down'))
14+
15+
const changeSlide = (direction) => {
16+
const sliderHeight = sliderContainer.clientHeight
17+
if(direction === 'up') {
18+
activeSlideIndex++
19+
if(activeSlideIndex > slidesLength -1 ) {
20+
activeSlideIndex = 0
21+
}
22+
} else if(direction === 'down') {
23+
activeSlideIndex--
24+
if(activeSlideIndex < 0) {
25+
activeSlideIndex = slidesLength - 1
26+
}
27+
}
28+
29+
slideRight.style.tranform = `translateY(-${activeSlideIndex * sliderHeight}px)`
30+
slideLeft.style.tranform = `translateY(${activeSlideIndex * sliderHeight}px)`
31+
32+
}
33+

vertical-slider/style.css

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
@import url('https://fonts.googleapis.com/css?family=Open+Sans');
2+
3+
* {
4+
box-sizing: border-box;
5+
margin: 0;
6+
padding: 0;
7+
}
8+
9+
body {
10+
font-family: 'Open Sans', sans-serif;
11+
height: 100vh;
12+
}
13+
14+
.slider-container{
15+
position: relative;
16+
overflow: hidden;
17+
width: 100vw;
18+
height: 100vh;
19+
}
20+
21+
.left-slide {
22+
height: 100%;
23+
width: 35%;
24+
position: absolute;
25+
top: 0;
26+
left: 0;
27+
transition: transform .5s ease-in-out
28+
}
29+
30+
.left-slide > div {
31+
height: 100%;
32+
width: 100%;
33+
display: flex;
34+
flex-direction: column;
35+
align-items: center;
36+
justify-content: center;
37+
color: #fff;
38+
}
39+
40+
.left-slide h1 {
41+
font-size: 40px;
42+
margin-bottom: 10px;
43+
margin-top: -30px;
44+
}
45+
46+
.right-slide {
47+
height: 100%;
48+
width: 65%;
49+
position: absolute;
50+
top: 0;
51+
left: 35%;
52+
transition: transform .5s ease-in-out
53+
}
54+
55+
.right-slide > div {
56+
background-repeat: no-repeat;
57+
background-size: cover;
58+
background-position: center center;
59+
height: 100%;
60+
width: 100%;
61+
}
62+
63+
button {
64+
background-color: #fff;
65+
border: none;
66+
color: #aaa;
67+
cursor: pointer;
68+
font-size: 16px;
69+
padding: 15px;
70+
}
71+
72+
button:hover {
73+
color: #222;
74+
}
75+
76+
button:focus {
77+
outline: none;
78+
}
79+
80+
.slider-container .action-buttons button {
81+
position: absolute;
82+
left: 35%;
83+
top: 50%;
84+
z-index: 100;
85+
}
86+
87+
.slider-container .action-buttons .down-button {
88+
transform: translateX(-100%);
89+
border-top-left-radius: 5px;
90+
border-bottom-left-radius: 5px;
91+
}
92+
93+
.slider-container .action-buttons .up-button {
94+
transform: translateY(-100%);
95+
border-top-right-radius: 5px;
96+
border-bottom-right-radius: 5px;
97+
}

0 commit comments

Comments
 (0)