Pressing on the accordion button, I’d likt to wait until accordion body will be computed, and just after this expand its content.
Otherwise expanding happens in several stages as appending new elements to accordion body. Non-smooth.
const ab = document.querySelector('.accordion-button');
ab.addEventListener('click', abListener);
function abListener(ev) {
// Heavy DOM work to build accordion body;
}
I thought I could make it by using preventDefault
method. but accordion still axpands.
ab.addEventListener('click', abListener);
// mouseup, mousedown and so on...
function abListener(ev) {
ev.preventDefault();
// Heavy DOM work to build accordion body;
setTimeout(() => { /* Manually expand the accordion; */ }, 0);
}
Thank you.