From 43a09369f27ff19fbebe3727d91c5c556b7c2b8e Mon Sep 17 00:00:00 2001 From: Said Achmiz Date: Tue, 11 Feb 2020 23:47:35 -0500 Subject: [PATCH] Improved nav UI hiding behavior on mobile --- assets/js/script.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/assets/js/script.js b/assets/js/script.js index 450d5d8..ba8227d 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -394,16 +394,22 @@ function updateSiteNavUIState(event) { if (!GW.scrollState.siteNavUI[0].hasClass("hidden")) toggleSiteNavUI(); } - // On mobile, make site nav UI translucent on ANY scroll down. -// if (GW.mediaQueries.mobileNarrow.matches) - GW.scrollState.siteNavUI.forEach(element => { - if (GW.scrollState.unbrokenDownScrollDistance > 0) element.addClass("translucent-on-scroll"); - else element.removeClass("hidden"); - }); + // Make site nav UI translucent when scrolling down. + GW.scrollState.siteNavUI.forEach(element => { + if (GW.scrollState.unbrokenDownScrollDistance > 0) element.addClass("translucent-on-scroll"); + else element.removeClass("hidden"); + }); - // Show site nav UI when scrolling a full page up, or to the top. - if ((GW.scrollState.unbrokenUpScrollDistance > window.innerHeight || - GW.scrollState.lastScrollTop == 0)) showSiteNavUI(); + // On desktop, show site nav UI when scrolling a full page up, or to the + // the top of the page. + // On mobile, show site nav UI translucent on ANY scroll up. + if (GW.mediaQueries.mobileNarrow.matches) { + if (GW.scrollState.unbrokenUpScrollDistance > 0) + showSiteNavUI(); + } else if ( GW.scrollState.unbrokenUpScrollDistance > window.innerHeight + || GW.scrollState.lastScrollTop == 0) { + showSiteNavUI(); + } } function toggleSiteNavUI() {