Welcome to mirror list, hosted at ThFree Co, Russian Federation.

main.js « js « assets - github.com/wayjam/hugo-theme-mixedpaper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6503c3ade3351ad6b218716d2184d51b76afabd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function() {
  const backToTopBtn = document.getElementById("back_to_top");

  window.onscroll = function() {
    scrollFunction(backToTopBtn);
  };
})();

function scrollFunction(btn) {
  const pageOffset =
    document.documentElement.scrollTop || document.body.scrollTop;
  if (btn) btn.style.visibility = pageOffset > 450 ? "visible" : "hidden";
}

// When the user clicks on the button, scroll to the top of the document
function backToTop() {
  document.body.scrollTop = 0; // For Safari
  document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}