first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
export function bindScrollToTop(button) {
|
||||
if (!button) return;
|
||||
|
||||
function updateVisibility() {
|
||||
button.hidden = window.scrollY <= 480;
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', updateVisibility, { passive: true });
|
||||
button.addEventListener('click', () => {
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
window.scrollTo({ top: 0, behavior: reduceMotion ? 'auto' : 'smooth' });
|
||||
});
|
||||
updateVisibility();
|
||||
}
|
||||
Reference in New Issue
Block a user