queue([queueName], newQueue)


version 1.2 以降

解説

マッチした要素のキューを、指定されたキューで置き換えます。

引数

  • [queueName]オプション
    String: キューの名前。指定しない場合は、デフォルトの fx キューを置き換えます。
  • newQueue
    Array<Function>: 置き換える関数の配列

戻り値

  • jQuery: jQueryオブジェクト

例1:アニメーションが実行される毎に、キュー内の関数の数を表示します。

// アニメーション
$("#test1_run").click(function(){
    $("#test1 .block")
        .animate({height:   "0px",   opacity: 0.2}, 1500, showQueueLength)
        .animate({height:   "200px", opacity: 1.0}, 2000, showQueueLength)
        .animate({fontSize: "2.0em"}, 1500, showQueueLength)
        .animate({width:    "150px"}, 1500, showQueueLength)
        .animate({fontSize: "1.0em"}, 1500, showQueueLength)
        .animate({width:    "100px"}, 2000, showQueueLength)

    showQueueLength();
});

// キューの数を表示
function showQueueLength(){
    $("#count").text($("#test1 .block").queue().length);
};

// キューを空で置き換え
$("#test1_clear").click(function(){
    $("#test1 .block")
        .queue([])       // 空の配列で置き換え
        .stop();         // 実行中のアニメーションを停止
    showQueueLength();   // キュー内の関数の数を表示 => 0
});


テスト1

キュー内の関数の数:0

.block