2012-05-09 9 views
3

簡単なマウス入力とマウスの離しアニメーションを作成します。あなたがマウスを入力するとdivを入力します。リンクdivよりもオープンしています。マウスを離すと、divは閉じられます。私は、slideUpとslideDownでアニメーションを設定しました。マウスを動かしてアニメーションを残す

私はアニメーションに問題があります。ページに.comment divsがたくさんあります。アイテムの上をすばやく移動したとき。スライドのアニメーションが狂ってしまい、アニメーションが何度も見えます。どうすれば修正できますか?ありがとう!

$("#comments .comment .links").hide(); 
$("#comments .comment").mouseenter(function() { 
    $(".links",this).slideDown(300); 
}).mouseleave(function() { 
    $(".links",this).slideUp(300); 
}); 
+0

日曜日!このhttp://jsfiddle.net/hMx9p/スライドの別のバージョンを共有する場合は、マウスを使用したいと思っています。 –

答えて

6

使用stop(true)各イベントにアニメーションキューをクリアする:

$("#comments .comment .links").hide(); 
$("#comments .comment").mouseenter(function() { 
    $(".links",this).stop(true).slideDown(300); 
}).mouseleave(function() { 
    $(".links",this).stop(true).slideUp(300); 
}); 

また、あなたがhover()を使用してこのコードを凝縮できます。あなたは何それはに何をすべきか行動

$("#comments .comment .links").hide(); 
$("#comments .comment").hover(
    function() { $(".links", this).stop(true).slideDown(300); }, 
    function() { $(".links", this).stop(true).slideUp(300); } 
); 
2

行う?アニメーションを開始する前に他のアニメーションをアニメーションで止めることができます。

$("#comments .comment").mouseenter(function() { 
    $("#comments .comment").stop(); 
    $(".links",this).slideDown(300); 
}).mouseleave(function() { 
    $(".links",this).slideUp(300); 
}); 
+0

ありがとうございます –

0

ここに同じ問題があります。

$( "#のspezial_navi_btn_20")のMouseEnter(関数(){

$("#content").stop(true).fadeOut("slow"); 
    $("#spezial_navi").css('background-image', 'url(http://#)'); 
    $("#spezial_navi_20").stop(true, true).slideUp("fast"); 
    $("#spezial_navi_desc_20").stop(true, true).slideDown('slow', function() { 
     $("body").ezBgResize({ 
     img : "http://#", 
     opacity : 1, 
     center : true 
     }); 
    }); 
    $("#spezial_navi_desc_30").stop(true, true).slideUp('slow'); 
    $("#spezial_navi_30").stop(true, true).slideDown('slow'); 
    $("#spezial_navi_desc_40").stop(true, true).slideUp('slow'); 
    $("#spezial_navi_40").stop(true, true).slideDown('slow'); 
}); 

解決しよう!! の代わりに:。。 $( "#のspezial_navi_20")が停止(真、真)。スクロールダウン( 'スロー'、ファンクション){ 私は: $( "#spezial_navi_20")。slideUp( "fast"); と: $( "#spezial_navi_desc_20")。 ( "高速"); と: $( "#spezial_navi_desc_20")。slideDown( 'slow'、function(){

関連する問題