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
pull/2554/head
thollander 5 years ago committed by Conduitry
parent adcd13f6dd
commit 93f7ecca1d

@ -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; let last_scroll = 0;
function handle_scroll() { function handle_scroll() {
const scroll = window.pageYOffset; const scroll = window.pageYOffset;
visible = (scroll < 50 || scroll < last_scroll); if (!hash_changed) {
visible = (scroll < 50 || scroll < last_scroll);
}
last_scroll = scroll; last_scroll = scroll;
hash_changed = false;
} }
</script> </script>
@ -227,7 +236,7 @@
} }
</style> </style>
<svelte:window on:scroll={handle_scroll}/> <svelte:window on:hashchange={handle_hashchange} on:scroll={handle_scroll} />
<header class:visible="{visible || open}"> <header class:visible="{visible || open}">
<nav> <nav>

Loading…
Cancel
Save