How can I achieve height animation in reverse?
Instead of the typical animation starting from the top and working its way down, how can I have it start the animation from the bottom of the element and work its way up towards the top of the element?
The event is triggered by a#link-1
, the animation takes place in div#line-1
.
This is my code: It doesn't appear to be working. :-/
HTML
<div id="pageContainer">
<div id="line-1"></div>
<a id="link-1" title="" href="#">Link 1</a>
</div><!-- end #pageContainer -->
CSS
#pageContainer{
position: relative;
margin: 0px 0px 200px 0px;
min-height: 748px;
height: 748px;
background: url('../img/sprite.png') bottom center no-repeat;
}
a#link-1{
position: absolute;
top: 686px;
left: 36px;
text-align: center;
display: block;
width: 76px;
height: 24px;
line-height: 24px;
z-index: 20;
}
div#line-1{
position: absolute;
top: 4px;
left: 30px;
width: 340px;
height: 687px;
background: url('../img/sprite.png') 0px 0px no-repeat;
}
JS
// Initially hide
$("div#line-1").hide();
// Activate Line 1
$('a#link-1').click(function() {
$('div#line-1').animate({
opacity: 0.25,
height: 'toggle'
}, 5000, function() {
// Animation complete.
});
});