-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathscript.js
25 lines (21 loc) · 832 Bytes
/
script.js
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
/* eslint-disable */
document.addEventListener("DOMContentLoaded", () => {
const loadingText = document.querySelector(".loading-text");
const bg = document.querySelector(".bg");
let load = 0;
// Function to update the loading state and apply styles
const blurring = () => {
load++;
if (load > 99) {
clearInterval(intervalId);
}
loadingText.innerText = `${load}%`;
loadingText.style.opacity = scale(load, 0, 100, 1, 0);
bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`;
};
// Start the interval to run the blurring function every 20ms
const intervalId = setInterval(blurring, 20);
// Utility function to scale a number from one range to another
const scale = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
});