Bootstrap class toggling
Best Adobe Community,
Initially I want to make clear that I have begun with an earlier Bootstrap version (v3.3.7) and it works well for my purposes.
I have added icon bars to the panel heading of the accordion. What I want is the most effective and reliable way of toggling the class of the icon bar (maybe similar to the toggling of the menu). I have namely added two icon bars with CSS transform to form a cross as the panel is opened.
I tried, for fun, adding JavaScript onclick but the problem with that was the independence of the collapsing of the panel. If you clicked fast enough, the transformation of the icon bars would switch (giving me a cross when the panel is collapsed)... Suppose you can work around this by adding event listeners of the CSS transition.
But I'd prefer what I achieved with the menu toggling. Discerning between two states simply by two different CSS classes .navbar-toggle and .navbar-toggle.collapsed.
Below is first the HTML code (showing me having moved out the a tag to contain the panel-heading) and the CSS classes of one of the icon bars (the first is the default state): HTML:
<div id="accordion1" class="panel-group" role="tablist" aria-multiselectable="true">
<!-- .panel-group -->
<div class="panel panel-default">
<!-- .panel -->
<a href="#collapseOne1" class="gamma" data-toggle="collapse" data-parent="#accordion1">
<!-- a -->
<div class="panel-heading clearfix" role="tab">
<!-- .panel-heading -->
<div class="s_d">
<!-- .s_d -->
<span>Title</span>
<!-- /.s_d -->
</div>
<div class="s2_d">
<!-- .s2_d -->
<span id="icon_bar1" class="icon_bar icon_bar1"></span>
<span id="icon_bar2" class="icon_bar icon_bar2"></span>
<!-- /.s2_d -->
</div>
<!-- /.panel-heading -->
</div>
<!-- /a -->
</a>
<div id="collapseOne1" class="panel-collapse collapse">
<!-- .panel-collapse -->
<div class="panel-body">
<!-- .panel-body -->
Content for Accordion Panel 1
<!-- /.panel-body -->
</div>
<!-- /.panel-collapse -->
</div>
<!-- /.panel -->
</div>
<!-- /.panel-group -->
</div>
CSS:
#accordion1 .icon_bar1 {
-ms-transform:translate(0,15px);
-webkit-transform:translate(0,15px);
-moz-transform:translate(0,15px);
-o-transform:translate(0,15px);
transform:translate(0,15px);
-ms-transition:0.3s;
-webkit-transition:0.3s;
-moz-transition:0.3s;
-o-transition:0.3s;
transition:0.3s;
}
#accordion1 .icon_bar1_2 {
-ms-transform:translate(0,15px);
-ms-transform:rotate(45deg);
-webkit-transform:translate(0,15px);
-webkit-transform:rotate(45deg);
-moz-transform:translate(0,15px);
-moz-transform:rotate(45deg);
-o-transform:translate(0,15px);
-o-transform:rotate(45deg);
transform:translate(0,15px) rotate(45deg);
-ms-transition:0.3s;
-webkit-transition:0.3s;
-moz-transition:0.3s;
-o-transition:0.3s;
transition:0.3s;
}
Thank you so so much on beforehand!
Regards,
Andreas
