Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the Flash Issue during Reload #336

Merged
merged 4 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
<link href="./favicon/icon.ico" rel="icon" type="image/x-icon">
<style id="iconStyle"></style>

<script src="preload.js"></script>
<script defer src="languages.js"></script>
<script defer src="script.js"></script>
</head>

<body>
<!----------------------- Loading Screen Starting ----------------------->
<img src="https://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png" id="LoadingScreen" fetchpriority="high"/>

<!----------------------- ToDo List Setup Starting ----------------------->
<!-- ToDo Icon -->
<div class="todoListCont" id="todoListCont">
Expand Down
1 change: 1 addition & 0 deletions preload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* If not, see <https://www.gnu.org/licenses/>.
*/


// Check if alert has already been shown
if (!localStorage.getItem('alertShown')) {
// Show the alert after 4 seconds
Expand Down Expand Up @@ -1026,6 +1025,8 @@ document.addEventListener("DOMContentLoaded", () => {
selectedRadioButton.checked = true;
}
}
// Remove Loading Screen When the DOM and the Theme has Loaded
document.getElementById('LoadingScreen').style.display = "none";
// it is necessary for some elements not to blink when the page is reloaded
setTimeout(() => {
document.documentElement.classList.add('theme-transition');
Expand Down Expand Up @@ -1517,6 +1518,7 @@ const applySelectedTheme = (colorValue) => {
if (faviconLink && iconPaths[colorValue]) {
faviconLink.href = iconPaths[colorValue];
}
ApplyLoadingColor();
};

// ----Color Picker || ColorPicker----
Expand Down Expand Up @@ -1588,6 +1590,7 @@ const applyCustomTheme = (color) => {
document.documentElement.style.setProperty('--whitishColor-blue', '#ffffff');
document.getElementById("rangColor").style.borderColor = color;
document.getElementById('dfChecked').checked = false;
ApplyLoadingColor();
};

// Load theme on page reload// Load theme on page reload
Expand Down Expand Up @@ -3223,3 +3226,10 @@ document.addEventListener("DOMContentLoaded", function () {
loadCheckboxState("fahrenheitCheckboxState", fahrenheitCheckbox);
loadShortcuts();
});

//------------------------- LoadingScreen -----------------------//

function ApplyLoadingColor(){
let LoadingScreenColor = getComputedStyle(document.body).getPropertyValue("background-color");
localStorage.setItem('LoadingScreenColor', LoadingScreenColor);
}
12 changes: 12 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2600,3 +2600,15 @@ input:checked + .toggle:before {
.savebtn:active {
transform: scale(0.96);
}

/* ---------------------- Loading Screen --------------------------- */
#LoadingScreen {
background: var(--Loading-Screen-Color);
display: flex;
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
z-index: 99999;
}