Sha256: 3c931e0b57c39602c5dd243b27651da9f625d94f2ce26c15306eaab0d64334bc

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

Contents

let userScrolled = false;

// Function to detect user scrolling
window.addEventListener("scroll", function () {
  userScrolled = true; // Set to true if the user scrolls
});

// Function to trigger the scroll hint
function scrollDownHint(times = 1, distance = 150, interval = 1000) {
  let count = 0;
  let scrollPosition = window.scrollY;

  function animateScroll() {
    if (count < times && !userScrolled) {
      window.scrollTo({
        top: scrollPosition + distance,
        behavior: "smooth",
      });

      setTimeout(() => {
        window.scrollTo({
          top: scrollPosition,
          behavior: "smooth",
        });
      }, interval / 2);

      count++;
      setTimeout(animateScroll, interval);
    }
  }

  animateScroll();
}

// Trigger the scroll hint only if the user hasn't scrolled within 3 seconds
window.onload = function () {
  setTimeout(() => {
    if (!userScrolled) {
      scrollDownHint();
    }
  }, 3000); // Wait for 3 seconds before triggering the scroll hint
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
awesome-jekyll-theme-1.2.0 assets/js/scrolldown-effect.js
awesome-jekyll-theme-1.1.0 assets/js/scrolldown-effect.js
awesome-jekyll-theme-1.0.1 assets/js/scrolldown-effect.js
awesome-jekyll-theme-1.0.0 assets/js/scrolldown-effect.js
awesome-jekyll-theme-0.3.1 assets/js/scrolldown-effect.js
awesome-jekyll-theme-0.3.0 assets/js/scrolldown-effect.js