From 7c8be59f2c9cccb76a28952892b5129f36a62e36 Mon Sep 17 00:00:00 2001 From: fynks <75840152+fynks@users.noreply.github.com> Date: Sun, 22 Mar 2026 23:54:15 +0500 Subject: [PATCH] feat: implement back-to-top button functionality with visibility toggle and smooth scroll behavior --- dist/js/app.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dist/js/app.js b/dist/js/app.js index ba85d74..0b65257 100644 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -2136,6 +2136,28 @@ const UIFeatures = (() => { window.addEventListener('scroll', throttledUpdate, { passive: true }); }; + // Back-to-top button behavior + const setupBackToTop = () => { + const backToTop = document.getElementById('backToTop'); + if (!backToTop) return; + + const prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches; + + const updateVisibility = () => { + backToTop.classList.toggle('visible', window.pageYOffset > 300); + }; + + updateVisibility(); + window.addEventListener('scroll', Utils.throttle(updateVisibility), { passive: true }); + + backToTop.addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: prefersReduced ? 'auto' : 'smooth' + }); + }); + }; + // Navigation highlight const setupNavHighlight = () => { if (!('IntersectionObserver' in window)) return; @@ -2202,6 +2224,7 @@ const UIFeatures = (() => { return Object.freeze({ setupScrollAnimations, setupHeaderElevation, + setupBackToTop, setupNavHighlight, setupURLComparison, setupOfflineDetection