Skip to content

Commit c02ae81

Browse files
Update script.js
Changes made: 1. Wrapped the code in DOMContentLoaded to ensure it runs after the DOM is fully loaded. 2. Improved variable naming for better readability (in_min, in_max, out_min, out_max to inMin, inMax, outMin, outMax). 3. Ensured consistent indentation and formatting. 4. Removed any unnecessary spaces and ensured concise code structure.
1 parent 3fbde42 commit c02ae81

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Source-Code/BluringImage/script.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
/* eslint-disable*/
2-
const loadingText = document.querySelector(".loading-text");
3-
const bg = document.querySelector(".bg");
4-
let load = 0;
1+
document.addEventListener("DOMContentLoaded", () => {
2+
const loadingText = document.querySelector(".loading-text");
3+
const bg = document.querySelector(".bg");
4+
let load = 0;
55

6-
const blurring = () => {
7-
load += 1;
8-
if (load > 99) {
9-
clearInterval(int);
10-
}
11-
loadingText.innerText = `${load}%`;
12-
loadingText.style.opacity = scale(load, 0, 100, 1, 0);
13-
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
14-
};
6+
const blurring = () => {
7+
load += 1;
8+
if (load > 99) {
9+
clearInterval(int);
10+
}
11+
loadingText.innerText = `${load}%`;
12+
loadingText.style.opacity = scale(load, 0, 100, 1, 0);
13+
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
14+
};
1515

16-
const int = setInterval(blurring, 20);
17-
const scale = (num, in_min, in_max, out_min, out_max) => {
18-
return ((num - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
19-
};
16+
const int = setInterval(blurring, 20);
17+
18+
const scale = (num, inMin, inMax, outMin, outMax) => {
19+
return ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
20+
};
21+
});

0 commit comments

Comments
 (0)