Sha256: 5b259230543a37c1cc65d4d382ff45fab97590723ff1bfa137d86826e069c3f8

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

(function () {
  const SCROLL_TOP = 120;

  function onScroll() {
    const topper = document.getElementById("topper");
    if (
      document.body.scrollTop > SCROLL_TOP ||
      document.documentElement.scrollTop > SCROLL_TOP
    ) {
      topper.style.display = "flex";
    } else {
      topper.style.display = "none";
    }
  }

  function onClick() {
    document.body.scrollTop = 0; // safari
    document.documentElement.scrollTop = 0;
    window.location.hash = '';
    history.pushState({}, document.title, window.location.href.split('#')[0]);
  }

  function init() {
    window.addEventListener("scroll", onScroll);
    onScroll();

    const topper = document.getElementById("topper");
    topper.addEventListener("click", onClick);
  }

  window.addEventListener("load", init);
})();

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-theme-shikhalev-0.1.0.8 assets/js/topper.js
jekyll-theme-shikhalev-0.1.0.6 assets/js/topper.js
jekyll-theme-shikhalev-0.1.0.5 assets/js/topper.js