|
46 | 46 | <img id="loading-image" src="./assets/load.gif" alt="Loading...">
|
47 | 47 |
|
48 | 48 | <script>
|
49 |
| - // Variable to track if the app has loaded |
50 |
| - let appLoaded = false; |
51 |
| - |
52 |
| - // Check for service worker registration and hide the loading image when ready |
53 |
| - if ('serviceWorker' in navigator) { |
54 |
| - window.addEventListener('flutter-first-frame', function () { |
55 |
| - navigator.serviceWorker.register('flutter_service_worker.js?v=900432827'); |
56 |
| - appLoaded = true; // Mark the app as loaded |
57 |
| - hideLoadingImage(); |
58 |
| - }); |
59 |
| - } |
60 |
| - |
61 |
| - // Function to hide the loading image |
62 |
| - function hideLoadingImage() { |
63 |
| - if (appLoaded) { |
64 |
| - document.getElementById('loading-image').style.display = 'none'; |
65 |
| - } |
66 |
| - } |
67 |
| - |
68 |
| - // Ensure the loading image is displayed for at least 3 seconds |
69 |
| - const minLoadTime = 3000; // 3 seconds |
70 |
| - const startTime = Date.now(); |
71 |
| - |
72 |
| - const interval = setInterval(() => { |
73 |
| - // Check if the minimum load time has passed and the app has loaded |
74 |
| - if (appLoaded && (Date.now() - startTime >= minLoadTime)) { |
75 |
| - hideLoadingImage(); |
76 |
| - clearInterval(interval); // Stop the interval check |
| 49 | + // Remove loading image after 10 seconds |
| 50 | + window.onload = function () { |
| 51 | + setTimeout(function () { |
| 52 | + var loadingIndicator = document.getElementById("loading-image"); |
| 53 | + if (loadingIndicator) { |
| 54 | + loadingIndicator.remove(); |
77 | 55 | }
|
78 |
| - }, 100); // Check every 100ms |
79 |
| - |
80 |
| - // If the minimum load time passes, hide the loading image regardless |
81 |
| - setTimeout(() => { |
82 |
| - appLoaded = true; // Set to true to bypass any further checks |
83 |
| - hideLoadingImage(); // Hide the loading image after 3 seconds if the app hasn't loaded |
84 |
| - }, minLoadTime); |
| 56 | + }, 10000); |
| 57 | + }; |
85 | 58 | </script>
|
86 | 59 |
|
87 | 60 | <script src="main.dart.js" type="application/javascript"></script>
|
|
0 commit comments