Is it possible to build an accordion with animate.css
I could not find any documentation to do this with animate.css. Is it possible to animate the change in height by applying a style or class to the accordion item div and animate the expanding div. Thanks
@vu-dang Use jQuery UI for something like that, and use a handler to detect whatever is opening and use some basic jQuery to append the animation class you want, and remove it if needed. Also, I think jQuery offers different transitions for the accordion. I could be wrong, so make sure to debug and check the documentation for jQuery (UI). Best of luck.
@vu-dang , @procodeing I think it can be done if we toggle classes like https://jsbin.com/figebi
@anshulguleria That is a very good idea
@anshulguleria your jsbin link doesn't work, any chance to have an explanation ? or a new jsbin ?
@marc-antoinepelletier Hi, sorry jsbin might have deleted link after some time. Here is link for demo https://jsbin.com/xofego Here is one way to do it:
<!-- html -->
<div class="accordion">
<div class="acc-content">
<div class="acc-head" data-target='#acc-body1'>Some heading 1</div>
<div id="acc-body1" class="acc-body hide animated">Some body 1</div>
</div>
<div class="acc-content">
<div class="acc-head" data-target='#acc-body2'>Some heading 2</div>
<div id="acc-body2" class="acc-body hide animated">Some body 2</div>
</div>
</div>
/* CSS */
,hide {
display: none;
}
// javascript
$(document).ready(() => {
// bind events to accordion
$('.acc-head').on('click', (ev) => {
let target = $(ev.target).attr('data-target');
let $target = $(target);
$target.toggleClass('hide zoomIn');
});
});
Also the earlier link might work now.