From 774bc75735f234b5ba419843ba3016432771d387 Mon Sep 17 00:00:00 2001 From: Nasir Anthony Montalvo Date: Mon, 9 Mar 2026 01:40:49 -0500 Subject: [PATCH] fianlly fixed STT button (window scroll event fixes) --- _includes/scroll-to-top.html | 72 ++++++++++++++++++++---------------- _sass/_custom.scss | 9 +++-- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/_includes/scroll-to-top.html b/_includes/scroll-to-top.html index 1002ca6..ba9b812 100644 --- a/_includes/scroll-to-top.html +++ b/_includes/scroll-to-top.html @@ -1,35 +1,45 @@ - - - Back to top - - - + + Back to top + + + + + function onScroll() { + btn.style.display = getScrolled() > 300 ? "block" : "none"; + } + + window.addEventListener("scroll", onScroll, { passive: true }); + document.addEventListener("scroll", onScroll, { passive: true }); + document.body.addEventListener("scroll", onScroll, { passive: true }); + + function scrollToTop(e) { + e.preventDefault(); + e.stopPropagation(); + + try { window.scrollTo({ top: 0, behavior: "smooth" }); } catch(e) {} + try { document.documentElement.scrollTo({ top: 0, behavior: "smooth" }); } catch(e) {} + try { document.body.scrollTo({ top: 0, behavior: "smooth" }); } catch(e) {} + } + + btn.addEventListener("click", scrollToTop); + btn.addEventListener("touchend", scrollToTop, { passive: false }); + +})(); + \ No newline at end of file diff --git a/_sass/_custom.scss b/_sass/_custom.scss index 657e361..f953a1e 100644 --- a/_sass/_custom.scss +++ b/_sass/_custom.scss @@ -1265,15 +1265,18 @@ figure { } /* ============================================================================ - SCROLL TO TOP - FULL STYLING (all viewports) + SCROLL TO TOP ============================================================================ */ #scroll-to-top { position: fixed; bottom: 4.5rem; right: 1rem; - z-index: 9999; - transition: transform 0.2s ease, box-shadow 0.2s ease; + z-index: 9999; + display: none; + touch-action: manipulation; + cursor: pointer; + -webkit-tap-highlight-color: transparent; } #scroll-to-top:hover {