2010-11-22 9 views
0

1つのスクリプトに問題があります。アニメーションはキューイングを続けます。あなたのフォーラムで解決策を探しました。私はストップ(真、真)とそのいくつかのバリエーションとキューを待ちました:偽。Jqueryアニメーションキューの問題

たぶん私は間違った場所に置いているかもしれませんが、私はまだjQueryに100%快適ではありません。

この時点での機能は次のとおりです。あなたが.animate()メソッドの前にそれを置く場合

jQuery(document).ready(function($) { 
    $('div.wp-caption').each(function(i) { 

     var img_ = $('img', this);   
     var img_height = img_.attr('height'); 
     var p_height = $('p', this).outerHeight(); 

     $(this).height(img_height); 

     $(this).hover(function() { 
      img_.animate({marginTop : -p_height}, 500); 
     }, function() { 
      img_.animate({marginTop : '0'}, 500); 
     });     
    });  
}); 

答えて

3

stop()はうまく動作するはずです:

$(this).hover(function() { 
    img_.stop().animate({marginTop : -p_height}, 500); 
}, function() { 
    img_.stop().animate({marginTop : '0'}, 500); 
}); 
+0

.stop()を入れてみてくださいおかげでたくさんの、魅力のように働きました! – user516144

1

は、アニメーションキューをクリアしてみてください。

  $(this).hover(function() { 
       img_.stop(true, true).animate({marginTop : -p_height}, 500); 
      }, function() { 
       img_.stop(true, true).animate({marginTop : '0'}, 500); 
      }); 

true, true引数はキューをクリアするためのjQueryを伝えますアニメーションの最後にジャンプします。

+0

いいね!それは確かに便利になるでしょう。 =) – user516144

1

.animate

$(this).hover(function() { 
    img_.stop().animate({marginTop : -p_height}, 500); 
}, function() { 
    img_.stop().animate({marginTop : '0'}, 500); 
}); 
+0

乾杯!寄付いただきありがとうございます。 – user516144