Back-to-Top Button auf allen Seiten hinzugefügt mit Smooth-Scroll und Fade-in/out Effekt

This commit is contained in:
2026-02-11 19:09:09 +01:00
parent c535c7c448
commit a39403abd1
6 changed files with 76 additions and 9 deletions

View File

@@ -194,3 +194,28 @@ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
}
});
});
// Back to Top Button
document.addEventListener('DOMContentLoaded', () => {
const backToTopButton = document.getElementById('back-to-top');
if (backToTopButton) {
// Button bei Scroll anzeigen/verstecken
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
backToTopButton.classList.add('show');
} else {
backToTopButton.classList.remove('show');
}
});
// Button Klick-Event
backToTopButton.addEventListener('click', (e) => {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
});