✨feature: Add responsive styles
This commit is contained in:
16
app.js
16
app.js
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user