Skip to content

Commit

Permalink
fix: fix navbar disappearing after link click (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
saicaca committed Sep 16, 2024
1 parent f0754ca commit 44fb628
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ function disableAnimation() {
}
*/

const bannerEnabled = !!document.getElementById('banner-wrapper')

function setClickOutsideToClose(panel: string, ignores: string[]) {
document.addEventListener("click", event => {
let panelDom = document.getElementById(panel);
Expand Down Expand Up @@ -325,6 +327,9 @@ const setup = () => {
document.documentElement.style.setProperty('--content-delay', '0ms')

// prevent elements from overlapping the navbar
if (!bannerEnabled) {
return
}
let threshold = window.innerHeight * 0.30 - 72 - 16
let navbar = document.getElementById('navbar-wrapper')
if (!navbar || !document.body.classList.contains('lg:is-home')) {
Expand Down Expand Up @@ -372,7 +377,6 @@ if (window?.swup?.hooks) {
}

let backToTopBtn = document.getElementById('back-to-top-btn');
const bannerEnable = !!document.getElementById('banner-wrapper')
let navbar = document.getElementById('navbar-wrapper')
function scrollFunction() {
if (backToTopBtn) {
Expand All @@ -383,7 +387,7 @@ function scrollFunction() {
}
}

if (!bannerEnable) return
if (!bannerEnabled) return
if (navbar) {
let threshold = window.innerHeight * 0.30 - 72 - 16
if (document.body.classList.contains('lg:is-home') && window.innerWidth >= 1024) {
Expand Down

0 comments on commit 44fb628

Please sign in to comment.