Skip to content

Commit a57b581

Browse files
committed
Encapsulating CSS styles, moving function excution into LoadEager execution context.
1 parent 1bf3336 commit a57b581

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

blocks/cloud-image/cloud-image.css

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
.cloud-image-wrapper {
22
height: 100vh;
33
position: relative;
4-
}
5-
64

7-
.icon.icon-logo-big {
8-
height: 100px;
9-
width: 140px;
10-
}
5+
.cloud-image {
6+
height: 100%;
7+
8+
& h1:first-of-type {
9+
font-size: clamp(2rem, 7vw + .25rem, 5.625rem);
10+
}
1111

12-
.cloud-image {
13-
height: 100%;
14-
15-
& h1:first-of-type {
16-
font-size: clamp(2rem, 7vw + .25rem, 5.625rem);
12+
.icon.icon-logo-big {
13+
height: 100px;
14+
width: 140px;
15+
}
16+
17+
.cloud-image-header {
18+
position: absolute;
19+
width: 100%;
20+
top: 50%;
21+
left: 50%;
22+
transform: translate(-50%, -50%);
23+
opacity: 1;
24+
z-index: 1;
25+
}
26+
27+
.cloud-image-element {
28+
position: absolute;
29+
top: 0;
30+
left: 0;
31+
max-width: 60vw;
32+
max-height: 40vh;
33+
animation: cloud 36s infinite;
34+
animation-delay: 0s;
35+
opacity: 0;
36+
z-index: 0;
37+
}
1738
}
1839
}
1940

20-
.cloud-image-header {
21-
position: absolute;
22-
width: 100%;
23-
top: 50%;
24-
left: 50%;
25-
transform: translate(-50%, -50%);
26-
opacity: 1;
27-
z-index: 1;
28-
29-
}
30-
31-
.cloud-image-picture {
32-
position: absolute;
33-
top: 0;
34-
left: 0;
35-
max-width: 60vw;
36-
max-height: 40vh;
37-
animation: cloud 36s infinite;
38-
animation-delay: 0s;
39-
opacity: 0;
40-
z-index: 0;
41-
}
42-
4341
/* Keyframe cloud animation */
4442
@keyframes cloud {
4543
0% {

blocks/cloud-image/cloud-image.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function addClassToDivsWithPicture() {
1212

1313
childDivs.forEach((div) => {
1414
if (div.querySelector('picture')) {
15-
div.classList.add('cloud-image-picture');
15+
div.classList.add('cloud-image-element');
1616
}
1717
});
1818
});
@@ -32,7 +32,7 @@ function setDataAttributes() {
3232
4, 5, 2, 34, 3, 7, 8,
3333
9, 15, 15, 12, 22, 20, 26, 33, 31, 25, 27,
3434
];
35-
const cloudImagePictureElements = document.querySelectorAll('.cloud-image-picture');
35+
const cloudImagePictureElements = document.querySelectorAll('.cloud-image-element');
3636

3737
cloudImagePictureElements.forEach((div, index) => {
3838
const leftIndex = index % leftValues.length;
@@ -46,7 +46,7 @@ function setDataAttributes() {
4646

4747
function positionImageInTheCloud() {
4848
const cloudImgContainer = document.querySelector('.cloud-image-wrapper');
49-
const cloudImagePictureElements = document.querySelectorAll('.cloud-image-picture');
49+
const cloudImagePictureElements = document.querySelectorAll('.cloud-image-element');
5050

5151
const {
5252
width: containerWidth,

scripts/scripts.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ async function loadEager(doc) {
8181
document.body.classList.add('appear');
8282
await loadSection(main.querySelector('.section'), waitForFirstImage);
8383
}
84-
8584
try {
8685
/* if desktop (proxy for fast connection) or fonts already loaded, load fonts.css */
8786
if (window.innerWidth >= 900 || sessionStorage.getItem('fonts-loaded')) {
@@ -90,6 +89,11 @@ async function loadEager(doc) {
9089
} catch (e) {
9190
// do nothing
9291
}
92+
/**
93+
* Executing function that manipulate position of the
94+
* cloud image block upon loading the page.
95+
*/
96+
positionImageInTheCloud();
9397
}
9498

9599
/**
@@ -125,8 +129,6 @@ async function loadPage() {
125129
await loadEager(document);
126130
await loadLazy(document);
127131
loadDelayed();
128-
// Executing function that manipulate position upon loading the page.
129-
positionImageInTheCloud();
130132
}
131133

132134
loadPage();

0 commit comments

Comments
 (0)