animate.css icon indicating copy to clipboard operation
animate.css copied to clipboard

Is it possible to build an accordion with animate.css

Open vu-dang opened this issue 11 years ago • 5 comments

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 avatar Aug 18 '15 06:08 vu-dang

@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.

procodeing avatar Aug 21 '15 01:08 procodeing

@vu-dang , @procodeing I think it can be done if we toggle classes like https://jsbin.com/figebi

anshulguleria avatar Aug 24 '15 10:08 anshulguleria

@anshulguleria That is a very good idea

procodeing avatar Aug 25 '15 00:08 procodeing

@anshulguleria your jsbin link doesn't work, any chance to have an explanation ? or a new jsbin ?

ghost avatar May 31 '16 11:05 ghost

@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.

anshulguleria avatar Jun 02 '16 04:06 anshulguleria