Skip to content

Commit da87291

Browse files
authored
Merge pull request #15 from Imran-imtiaz48/patch-3
Update script.js
2 parents 36f7cf4 + 036b277 commit da87291

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

Source-Code/BluringImage/script.js

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
// Disable ESLint for the entire file
2-
/* eslint-disable */
1+
document.addEventListener("DOMContentLoaded", () => {
2+
const loadingText = document.querySelector(".loading-text");
3+
const bg = document.querySelector(".bg");
4+
let load = 0;
5+
6+
// Function to update the loading state and apply styles
7+
const blurring = () => {
8+
load++;
9+
if (load > 99) {
10+
clearInterval(intervalId);
11+
}
12+
loadingText.innerText = `${load}%`;
13+
loadingText.style.opacity = scale(load, 0, 100, 1, 0);
14+
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
15+
};
316

4-
// Select DOM elements
5-
const loadingText = document.querySelector(".loading-text");
6-
const bg = document.querySelector(".bg");
17+
// Start the interval to run the blurring function every 20ms
18+
const intervalId = setInterval(blurring, 20);
719

8-
let load = 0;
9-
10-
// Function to update the loading state and apply styles
11-
const blurring = () => {
12-
load++;
13-
if (load > 99) {
14-
clearInterval(intervalId);
15-
}
16-
loadingText.innerText = `${load}%`;
17-
loadingText.style.opacity = scale(load, 0, 100, 1, 0);
18-
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
19-
};
20-
21-
// Start the interval to run the blurring function every 20ms
22-
const intervalId = setInterval(blurring, 20);
23-
24-
// Utility function to scale a number from one range to another
25-
const scale = (num, inMin, inMax, outMin, outMax) => {
26-
return ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
27-
};
20+
// Utility function to scale a number from one range to another
21+
const scale = (num, inMin, inMax, outMin, outMax) => {
22+
return ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
23+
};
24+
});

0 commit comments

Comments
 (0)