UPDATE: Recreated my problem in jsFiddle: http://jsfiddle.net/leongaban/3v8vW/3/
I have 2 tabs, clicking on short should shorten the height of the form-background, and clicking on tall should increase the height. However there should not be any jarring / 'skippy' animation going on like so.
When you click on a tab, the other tab is hidden.
Codepen: http://codepen.io/leongaban/pen/wipba
If you click on login you will see the animation happen. The login div has a height of 290px and register is 410px.
I got the animate code from this simple example here.
What I'm trying to do is just animate the height extending down or shrinking up, the position and width should stay the same. I had to set top
and width
because otherwise my .form-background
div would do some crazy resizing and not end at the correct position after the animation.
Do you know what is going on here? And how would you go about hacking it? :)
jQuery
// tabs
$('#login-form #tab-register').click(function() {
$('#login-form').fadeToggle();
$(".form-background").animate(
{
"top": "-342px",
"width": "400px",
"height": "410px"
},
"slow", function(){
$('#register-form').fadeToggle();
});
});
$('#register-form #tab-login').click(function() {
$('#register-form').fadeToggle();
$(".form-background").animate(
{
"top": "-214px",
"width": "400px",
"height": "290px"
},
"slow", function(){
$('#login-form').fadeToggle();
});
});
CSS
.container .login-container .login-box .form-background {
position: relative;
top: -342px;
height: 410px;
background: white;
-webkit-box-shadow: 0px 5px 15px rgba(50, 50, 50, 0.2);
-moz-box-shadow: 0px 5px 15px rgba(50, 50, 50, 0.2);
box-shadow: 0px 5px 15px rgba(50, 50, 50, 0.2);
z-index: -1;
}