|
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 | + }; |
3 | 16 |
|
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); |
7 | 19 |
|
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