panel/btn mobile & scripts
All checks were successful
Deploy / Deploy to Production (push) Successful in 11s
All checks were successful
Deploy / Deploy to Production (push) Successful in 11s
This commit is contained in:
parent
bd97c1c33e
commit
f28680f77e
26 changed files with 506 additions and 297 deletions
|
|
@ -1,6 +1,14 @@
|
|||
export function initDropdowns() {
|
||||
export function initDropdowns(responsiveSmall) {
|
||||
const dropdowns = document.querySelectorAll('.dropdown');
|
||||
|
||||
function updateBodyOverflow(isOpen) {
|
||||
if (isOpen && window.innerWidth < responsiveSmall) {
|
||||
document.body.classList.add('is-hidden');
|
||||
} else {
|
||||
document.body.classList.remove('is-hidden');
|
||||
}
|
||||
}
|
||||
|
||||
dropdowns.forEach(dropdown => {
|
||||
const trigger = dropdown.querySelector('.dropdown__trigger');
|
||||
const content = dropdown.querySelector('.dropdown__content');
|
||||
|
|
@ -44,6 +52,9 @@ export function initDropdowns() {
|
|||
// Toggle le dropdown actuel
|
||||
dropdown.classList.toggle('is-open');
|
||||
trigger.classList.toggle('is-selected');
|
||||
|
||||
// Gère l'overflow du body sur mobile
|
||||
updateBodyOverflow(dropdown.classList.contains('is-open'));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -57,6 +68,7 @@ export function initDropdowns() {
|
|||
dropdown.classList.remove('is-open', 'dropdown--align-right');
|
||||
dropdown.querySelector('.dropdown__trigger')?.classList.remove('is-selected');
|
||||
});
|
||||
updateBodyOverflow(false);
|
||||
});
|
||||
|
||||
// Ferme au press Escape
|
||||
|
|
@ -66,6 +78,7 @@ export function initDropdowns() {
|
|||
dropdown.classList.remove('is-open', 'dropdown--align-right');
|
||||
dropdown.querySelector('.dropdown__trigger')?.classList.remove('is-selected');
|
||||
});
|
||||
updateBodyOverflow(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue