beshoy semsem beshoy semsem - 3 months ago 7
Javascript Question

stop jquery until effect finished

i have this code

$(".menu").click(function( event ) {
event.preventDefault();
if ( !$( this ).hasClass("isDown") ) {
$(".menu-container").css("display", "block");
$(".menu-container")
.animate({ "height": "5%" }, 200 )
.animate({ "height": "2%" }, 200 )
.animate({ "height": "8%" }, 200 )
.animate({ "height": "100%" }, 1000 );
} else {
$(".menu-container")
.animate({ "height": "50%" }, 600 )
.animate({ "height": "65%" }, 200 )
.animate({ "height": "40%" }, 200 )
.animate({ "height": "0%" }, 400, function() {
$( this ).css("display", "none");
});

}
// use this class as indecator if menu open or not
$( this ).toggleClass("isDown");
return false;
});


when click more than time on this menu button effect repeated . How stop that ?
thanks in advance

Answer

Add animation before adding the following code:

if(!$(".menu-container").is(":animated"))