Files
RomhackPlaza/resources/js/mobile-back-to-top.js
Benjamin b422cd2c82 Fixed a lot of responsive problems.
- Fixed auth problem
- Fixed BBCode and Markdown apparition in some unnecessary parts
2026-07-01 11:51:30 +02:00

19 lines
593 B
JavaScript

export function initMobileBackToTop(){
const backToTopButton = document.querySelector('.back-to-top');
const content = document.getElementById('content');
if (!backToTopButton || !content) {
return;
}
const toggleBackToTop = () => {
const shouldShow = window.innerWidth <= 768 && content.scrollTop > 320;
backToTopButton.classList.toggle('visible', shouldShow);
};
toggleBackToTop();
content.addEventListener('scroll', toggleBackToTop, { passive: true });
window.addEventListener('resize', toggleBackToTop, { passive: true });
}