mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
✨ Added button to scroll back to the top
This commit is contained in:
@@ -308,6 +308,10 @@ function updateFilter(f) {
|
||||
document.querySelector('#f-' + queryOption).style.boxShadow = 'inset rgba(0, 0, 0, 0.40) 0 0 5px'
|
||||
}
|
||||
|
||||
function scrollTop() {
|
||||
window.scrollTo({top: 0, behavior: 'smooth'});
|
||||
}
|
||||
|
||||
document.addEventListener('click', e => {
|
||||
if (e.target.id !== 'suggestions' && e.target !== searchBar && e.target !== searchBarButton) {
|
||||
|
||||
@@ -347,6 +351,10 @@ document.addEventListener('click', e => {
|
||||
if (e.target.id.toString().includes('f-')) {
|
||||
updateFilter(e.target.id)
|
||||
}
|
||||
|
||||
if (e.target.classList.contains('scroll-to-top')) {
|
||||
scrollTop()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -359,6 +367,14 @@ navbarForm.addEventListener('submit', e => {
|
||||
submitForm(0)
|
||||
})
|
||||
|
||||
document.addEventListener('scroll', e => {
|
||||
if (window.scrollY != 0) {
|
||||
document.querySelector('#scrollToTop').style.display = 'block'
|
||||
} else {
|
||||
document.querySelector('#scrollToTop').style.display = 'none'
|
||||
}
|
||||
})
|
||||
|
||||
let urlSearch = urlParams.get('search')
|
||||
let urlOption = urlParams.get('option')
|
||||
let urlOffset = urlParams.get('offset')
|
||||
|
||||
Reference in New Issue
Block a user