From ddf004b709578a488a8c1c03478085460ba74cdd Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Thu, 25 Mar 2021 11:00:22 +0530 Subject: [PATCH] Allow disabling ScrollToTop button - refactor corresponding code usage => in site config: params: disableScrollToTop: true closes: #321 --- layouts/partials/footer.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 49e6061..f818e85 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -9,6 +9,7 @@ · Theme PaperMod +{{- if (not .Site.Params.disableScrollToTop) }} +{{- end }} {{- partial "extend_footer.html" . -}} {{- $isHLJSdisabled := (.Site.Params.assets.disableHLJS | default .Params.disableHLJS ) }} {{- if (and (eq .Kind "page") (ne .Layout "archives") (ne .Layout "search") (not $isHLJSdisabled)) }} @@ -34,6 +36,11 @@ document.getElementById('menu').scrollLeft = localStorage.getItem("menu-scroll-position"); } } + + function menu_on_scroll() { + localStorage.setItem("menu-scroll-position", document.getElementById('menu').scrollLeft); + } + document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener("click", function (e) { e.preventDefault(); @@ -52,6 +59,11 @@ } }); }); + + + +{{- if (not .Site.Params.disableScrollToTop) }} + +{{- end }} + {{- if (not .Site.Params.disableThemeToggle) }}