feature: Add responsive styles

This commit is contained in:
Keith Solomon
2025-09-01 12:54:16 -05:00
parent 6881f654a9
commit 93b7f7b49d
3 changed files with 89 additions and 23 deletions

16
app.js
View File

@@ -106,3 +106,19 @@ async function resetGame() {
}
window.addEventListener('DOMContentLoaded', onLoad);
// Back to Top: show after scrolling, smooth-scroll on click
function initBackToTop() {
const btn = document.getElementById('backToTop');
if (!btn) return;
const onScroll = () => {
if (window.scrollY > 200) btn.classList.add('show'); else btn.classList.remove('show');
};
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
btn.addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
}
window.addEventListener('DOMContentLoaded', initBackToTop);