Пытаюсь фиксануть раскртыие вопроса по дресскоду на мобилках

This commit is contained in:
Alexander Zaytsev 2026-06-05 11:24:47 +03:00 committed by GitHub
parent af3c30b2fb
commit 74d0523c69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -599,16 +599,6 @@ window.addEventListener('scroll', () => {
// ---- FAQ: аккордеон ---- // ---- FAQ: аккордеон ----
function setFaqAnswerHeight(answer, open) {
if (open) {
answer.classList.add('open');
answer.style.maxHeight = answer.scrollHeight + 'px';
} else {
answer.classList.remove('open');
answer.style.maxHeight = '0px';
}
}
document.querySelectorAll('.faq-question').forEach(btn => { document.querySelectorAll('.faq-question').forEach(btn => {
btn.addEventListener('click', () => { btn.addEventListener('click', () => {
const expanded = btn.getAttribute('aria-expanded') === 'true'; const expanded = btn.getAttribute('aria-expanded') === 'true';
@ -616,21 +606,12 @@ document.querySelectorAll('.faq-question').forEach(btn => {
document.querySelectorAll('.faq-question').forEach(b => { document.querySelectorAll('.faq-question').forEach(b => {
b.setAttribute('aria-expanded', 'false'); b.setAttribute('aria-expanded', 'false');
setFaqAnswerHeight(b.nextElementSibling, false); b.nextElementSibling.classList.remove('open');
}); });
if (!expanded) { if (!expanded) {
btn.setAttribute('aria-expanded', 'true'); btn.setAttribute('aria-expanded', 'true');
setFaqAnswerHeight(answer, true); answer.classList.add('open');
}
});
});
window.addEventListener('resize', () => {
document.querySelectorAll('.faq-question[aria-expanded="true"]').forEach(btn => {
const answer = btn.nextElementSibling;
if (answer.classList.contains('open')) {
answer.style.maxHeight = answer.scrollHeight + 'px';
} }
}); });
}); });