Skip to content

Commit

Permalink
Merge pull request #160 from hlxsites/accordion
Browse files Browse the repository at this point in the history
95: transition issue fixed
  • Loading branch information
davenichols-DHLS authored Nov 21, 2023
2 parents 8c7541f + 82ff0f9 commit 446ecd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion blocks/accordion/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ main .accordion.faq-accordion .faq-answer {
overflow: hidden;
font-size: 16px;
max-height: 0;
transition: all 0.5s ease-in-out;
transition: all 0.4s ease-in-out;
text-align: left;
}

Expand Down
25 changes: 15 additions & 10 deletions blocks/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,24 @@ export default function decorate(block) {
const openfaq = block.querySelector('.faq-question.active');
if (openfaq && !currentFaq) {
openfaq.classList.toggle('active');
openfaq.nextElementSibling.classList.toggle('active');
}
const faqAnswer = e.currentTarget.nextElementSibling;
e.currentTarget.classList.toggle('active');
if (e.currentTarget.classList.contains('active')) {
faqAnswer.classList.toggle('active');
faqAnswer.style.maxHeight = `${faqAnswer.scrollHeight}px`;
} else {
faqAnswer.style.maxHeight = 0;
openfaq.nextElementSibling.style.maxHeight = 0;
setTimeout(() => {
faqAnswer.classList.toggle('active');
openfaq.nextElementSibling.classList.toggle('active');
}, 300);
}
setTimeout(() => {
const faqAnswer = e.target.nextElementSibling;
e.target.classList.toggle('active');
if (e.target.classList.contains('active')) {
faqAnswer.classList.toggle('active');
faqAnswer.style.maxHeight = `${faqAnswer.scrollHeight}px`;
} else {
faqAnswer.style.maxHeight = 0;
setTimeout(() => {
faqAnswer.classList.toggle('active');
}, 300);
}
}, 300, e);
});
const faqAnswer = [...row.children][1];
faqAnswer.classList.add('faq-answer');
Expand Down

0 comments on commit 446ecd8

Please sign in to comment.