2016-08-25 4 views
0

が私のコードである終了まで:停止jqueryの効果は以下

$(".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; 
}); 

とき(メニューボタン)は効果が同様に繰り返し発生し、数回クリックします。

どうすればそれを防ぐことができますか?

答えて

0

次のコードを追加する前にアニメーションを追加します。

if(!$(".menu-container").is(":animated")) 
関連する問題