diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2023-05-05 03:16:06 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2023-05-05 03:16:06 -0600 |
commit | 70e783628b1bf863da45cc8879b06288a498840b (patch) | |
tree | 6a61d3134fbb100f0fc04e9e96782d29e24bb5ed /live/static/scripts | |
parent | ec2aa74d36670d74c153aa0022ab22e79502a061 (diff) |
update css, make articles more uniform, add toc and add functionality to scroll to the top
Diffstat (limited to 'live/static/scripts')
-rw-r--r-- | live/static/scripts/return_top.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/live/static/scripts/return_top.js b/live/static/scripts/return_top.js new file mode 100644 index 0000000..77c468f --- /dev/null +++ b/live/static/scripts/return_top.js @@ -0,0 +1,21 @@ +// Taken from https://www.w3schools.com/howto/howto_js_scroll_to_top.asp +// and tweaked as needed +document.addEventListener("DOMContentLoaded", function(event) { + let returnTopButton = document.getElementById("returnTopButton"); + let scrollTopAppearPX = window.screen.availHeight; + + window.onscroll = function() {scrolling(returnTopButton, scrollTopAppearPX)}; +}) + +function scrolling(returnButton, onScrollAppear) { + if (document.body.scrollTop > onScrollAppear || document.documentElement.scrollTop > onScrollAppear) { + returnButton.style.display = "inline-block"; + } else { + returnButton.style.display = "none"; + } +} + +function returnTop() { + document.body.scrollTop = 0; // For Safari + document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera +} |