From e1af430022146d3ea987f63984ea8a843dc5ed08 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev <36922661+GolwerShoden@users.noreply.github.com> Date: Tue, 2 Jun 2026 22:26:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=85=D1=83=D0=B9=D0=BD=D1=8E,=20=D1=88=D0=BE=D0=B1=20FAQ=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D1=81=D1=8C=20=D0=BD=D0=BE=D1=80=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=B1=D0=B8=D0=BB=D0=BA?= =?UTF-8?q?=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/burka_wed/script.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/services/burka_wed/script.js b/services/burka_wed/script.js index 929b30e..0a820f2 100644 --- a/services/burka_wed/script.js +++ b/services/burka_wed/script.js @@ -599,21 +599,38 @@ window.addEventListener('scroll', () => { // ---- 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 => { btn.addEventListener('click', () => { const expanded = btn.getAttribute('aria-expanded') === 'true'; const answer = btn.nextElementSibling; - // Закрыть все остальные document.querySelectorAll('.faq-question').forEach(b => { b.setAttribute('aria-expanded', 'false'); - b.nextElementSibling.classList.remove('open'); + setFaqAnswerHeight(b.nextElementSibling, false); }); - // Переключить текущий if (!expanded) { btn.setAttribute('aria-expanded', 'true'); - answer.classList.add('open'); + setFaqAnswerHeight(answer, true); + } + }); +}); + +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'; } }); });