A version of Jquery's but in TweenMax (Faster & Responsive)
Forked from aPinix's Pen TweenMax (slideToggle).
<div class="expander"> | |
<div class="header">Click Me</div> | |
<div class="content">I have an accordion and am animating the the height for a show reveal - the issue is the height which i need to set to auto as the information is different lengths.<br><br> | |
I have an accordion and am animating the the height fferent lengths. | |
</div> | |
</div> | |
<div class="expander"> | |
<div class="header">Click Me</div> | |
<div class="content">I have an accordion and am animating the the height for a show reveal - the issue is the height which i need to set to auto as the information is different lengths. | |
</div> | |
</div> | |
<div class="expander"> | |
<div class="header">Click Me</div> | |
<div class="content">the issue is the height which i need to set to auto as the information is different lengths.</div> | |
</div> |
$(".expander").click(function(){ | |
var $this = $(this), | |
$content = $this.find(".content"); | |
if(!$this.hasClass("closed")){ | |
TweenLite.to($content, 0.2, {height:0}) | |
$this.addClass("closed") | |
}else{ | |
//to open | |
// - temporarilty set height:auto | |
// - tween from height:0 | |
TweenLite.set($content, {height:"auto"}) | |
TweenLite.from($content, 0.2, {height:0}) | |
$this.removeClass("closed"); | |
} | |
}) |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script> |
.expander { | |
width:300px; | |
border:solid 1px #555; | |
padding:10px; | |
margin:10px; | |
cursor:pointer; | |
} | |
.content{ | |
overflow:hidden; | |
} |