@@ -2,20 +2,23 @@ document.addEventListener("DOMContentLoaded", () => {
22 const loadingText = document . querySelector ( ".loading-text" ) ;
33 const bg = document . querySelector ( ".bg" ) ;
44 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+ } ;
516
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- } ;
17+ // Start the interval to run the blurring function every 20ms
18+ const intervalId = setInterval ( blurring , 20 ) ;
1519
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- } ;
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+ } ;
2124} ) ;
0 commit comments