From 93f7ecca1d8fb90f7a1f8bfded3b03e0ab9e2b76 Mon Sep 17 00:00:00 2001 From: thollander Date: Tue, 23 Apr 2019 22:57:54 +0200 Subject: [PATCH] Don't show/hide nav when clicking in docs sidebar - Listens to hashchange event - Changes only the navbar visibilty when scroll not triggered by hashchange Resolves #2456 --- site/src/components/TopNav.svelte | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/site/src/components/TopNav.svelte b/site/src/components/TopNav.svelte index 4254e99152..49a1be50d1 100644 --- a/site/src/components/TopNav.svelte +++ b/site/src/components/TopNav.svelte @@ -35,12 +35,21 @@ }; }); + // Prevents navbar to show/hide when clicking in docs sidebar + let hash_changed = false; + function handle_hashchange() { + hash_changed = true; + } + let last_scroll = 0; function handle_scroll() { const scroll = window.pageYOffset; - visible = (scroll < 50 || scroll < last_scroll); + if (!hash_changed) { + visible = (scroll < 50 || scroll < last_scroll); + } last_scroll = scroll; + hash_changed = false; } @@ -227,7 +236,7 @@ } - +