cript> document.addEventListener("DOMContentLoaded", function () { let lastScrollY = window.scrollY; function toggleMobileButtons() { if (window.innerWidth <= 768) { const currentScrollY = window.scrollY; if (currentScrollY > 5) { document.body.classList.add("hide-mobile-top-buttons"); } else { document.body.classList.remove("hide-mobile-top-buttons"); } if (currentScrollY > lastScrollY && currentScrollY > 20) { document.body.classList.add("hide-mobile-bottom-buttons"); } else { document.body.classList.remove("hide-mobile-bottom-buttons"); } lastScrollY = currentScrollY <= 0 ? 0 : currentScrollY; } else { document.body.classList.remove("hide-mobile-top-buttons"); document.body.classList.remove("hide-mobile-bottom-buttons"); } } toggleMobileButtons(); window.addEventListener("scroll", toggleMobileButtons, { passive: true }); window.addEventListener("resize", toggleMobileButtons); });