diff --git a/assets/js/to-top.js b/assets/js/to-top.js new file mode 100644 index 0000000..3287f43 --- /dev/null +++ b/assets/js/to-top.js @@ -0,0 +1,20 @@ +var topbutton = document.getElementById('toTop'); + +if (topbutton !== null) { + + topbutton.style.display = 'none'; + window.onscroll = function() { + scrollFunction() + }; + +} + +function scrollFunction() { + + if (document.body.scrollTop > 40 || document.documentElement.scrollTop > 40) { + topbutton.style.display = 'block'; + } else { + topbutton.style.display = 'none'; + } + +} diff --git a/config/_default/params.toml b/config/_default/params.toml index 5780d96..f241b10 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -92,6 +92,7 @@ lastMod = false docsVersioning = false fullWidth = false navbarSticky = true + toTopButton = true [menu] [menu.section] diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b8b4273..561b8e2 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -23,5 +23,10 @@ {{ block "sidebar-footer" . }}{{ end }} {{ partial "footer/footer.html" . }} {{ partial "footer/script-footer.html" . }} + {{ if eq .Site.Params.options.toTopButton true -}} +