I created an accordion and trying to add transition effect whenever the user tries to click on the accordion header.
I added height: auto
and transitiion
to the accordion container, but this effort seems useless here.
var texts = document.getElementsByClassName('text');
[].slice.call(texts).forEach(function (text) {
text.onclick = function () {
text.parentElement.classList.toggle('animate');
}
});
PS: the height of each content differs and the animation should happen while opening and closing the content.
EDIT:
I tried the possible duplicate question solution, which isn't animating perfecting,
http://jsfiddle.net/9vuor3oo/5/
The animation works only while opening the accordion but not closing it. and also the last accordion doesn't even animate on opening.