Skip to content

Commit

Permalink
Merge pull request #132 from HarryDulaney/loading-fix
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
HarryDulaney authored Nov 5, 2023
2 parents 7abd4ca + e7f44b2 commit 2bd0dd3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@
<!--------------------------------------- Intro (Home) ------------------------------------------->
<template id="intro-page-template">
<div class="intro--wrapper">
<div id="scroll-anchor"></div>
<div class="intro">
<div class="container">
<div class="row w-100 m-0 p-0">
Expand Down
41 changes: 25 additions & 16 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ function navigate(navigateFn) {
if (INITIALIZED) {
animateTransition(document);
navigateFn();
hideLoader();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
navigateFn();
INITIALIZED = true;
hideLoader();
window.scrollTo({ top: 0, behavior: 'smooth' });
}

hideLoader();
window.scrollTo({ top: 0, behavior: 'smooth' });
}

/**
Expand Down Expand Up @@ -209,23 +211,28 @@ function toggleLoader() {
}

function showLoader() {
FOOTER_CONTAINER.classList.add('hide-footer');
NAV_BAR_CONTAINER.classList.add('hide-navbar');
FOOTER_CONTAINER.classList.remove('show-footer');
NAV_BAR_CONTAINER.classList.remove('show-navbar');
LOADER_CONTAINER.classList.add('show-loading');
LOADER_CONTAINER.classList.remove('hide-loading');
isLoading = true;
if (!isLoading) {
isLoading = true;
FOOTER_CONTAINER.classList.add('hide-footer');
NAV_BAR_CONTAINER.classList.add('hide-navbar');
FOOTER_CONTAINER.classList.remove('show-footer');
NAV_BAR_CONTAINER.classList.remove('show-navbar');
LOADER_CONTAINER.classList.add('show-loading');
LOADER_CONTAINER.classList.remove('hide-loading');
}

}

function hideLoader() {
LOADER_CONTAINER.classList.remove('show-loading');
LOADER_CONTAINER.classList.add('hide-loading');
FOOTER_CONTAINER.classList.remove('hide-footer');
NAV_BAR_CONTAINER.classList.remove('hide-navbar');
FOOTER_CONTAINER.classList.add('show-footer');
NAV_BAR_CONTAINER.classList.add('show-navbar');
isLoading = false;
if (isLoading) {
isLoading = false;
LOADER_CONTAINER.classList.remove('show-loading');
LOADER_CONTAINER.classList.add('hide-loading');
FOOTER_CONTAINER.classList.remove('hide-footer');
NAV_BAR_CONTAINER.classList.remove('hide-navbar');
FOOTER_CONTAINER.classList.add('show-footer');
NAV_BAR_CONTAINER.classList.add('show-navbar');
}
}

addTemplate('intro', function () {
Expand Down Expand Up @@ -258,6 +265,7 @@ $(window).on('hashchange', router);
$(window).on('load', router);
$(window).on('beforeunload', function () {
sessionStorage.setItem(PAGE_RELOADED_STORAGE_KEY, 'reloaded');
INITIALIZED = false;
});


Expand All @@ -270,6 +278,7 @@ $(window).ready(function () {
FOOTER_CONTAINER = document.querySelector('#footer-container');
NAV_BAR_CONTAINER = document.querySelector('#nav-container');
LOADER_CONTAINER = document.querySelector('#loader-container');
// const isReloaded = sessionStorage.getItem(PAGE_RELOADED_STORAGE_KEY, 'reloaded');
showLoader();
setNavMenuElementIds();
initializeTheme();
Expand Down

0 comments on commit 2bd0dd3

Please sign in to comment.