質問

ようにしている統合マッチングのようなもの:

$(".item").each(function(i) {
    //animation here
});

とjQueryの固有のチェーン機能が働き、アニメーションまでお待ち前のアニメーションが完了し、例えば:

$(".item").each(function(i) {
    $(this).animate({marginLeft:"0"}, 60);
});

そのトリガー。負荷機能のアニメは完了です。基本的には、いつの項目をフェードした[一次、すべてを一度にしてその荷重点項目の一部において、最初のです。

する方法を教えてくださいこれを再利用可能な/の変数となり得る。

役に立ちましたか?

解決 3

$("#more:not(.disabled)").live("click", function(event) {
    event.preventDefault();

    var urlPieces = (event.target.href).split("/");
    var nextURL = urlPieces[urlPieces.length - 2] + "/" + urlPieces[urlPieces.length - 1];
    var items = $(".item");
    var itemCount = items.length;   

    items.each(function(i) {
        var passthru = this;
        window.setTimeout(function() {
            $(passthru).animate({opacity:"0"}, 60, function() {
                if (i == itemCount - 1) {
                    $("#browse").load(nextURL + " .item, #controls", fadeInNew);
                }
            });
        }, 60*i);
    });
});

fadeInNewの新たな一つ一つがフェードで、他の場所ですがついていないのがちょっとした以下のエリアを表示一部のエリア追加のコードの周りにあるかを明らかに何が起きているのが、次の矢印のurl、そhref場合、当サイトでは、以下のブラウザは、さんありがとうございます。URLは次のページからの相対流の場合は、 このurlとしてhref、負荷の新しいページのコンテンツページ以外の項目されてい$.荷重-ed.

他のヒント

どの要素が最後のものであるかどうかをチェックして、コールバックを追加することについてはどうですか?

$(".item").each(function(i, elem) {
    var callback = $(elem).is(':last') ? function() {
        //dosomething
    } : function(){};
    $(this).animate({marginLeft:"0"}, {duration: 60, complete: callback);
});

ただ、アニメーションのためのコールバックを指定し、フェードアウトされているどのように多くのアイテムを追跡。その後、彼らはすべて完了したら、それらを削除し、新しいものを追加します。

var items = $('.item');
var parent = items.parent();
var itemCount = items.length;
items.each(function()
{
    $(this).fadeOut('medium', function()
    {
        itemCount--;
        if (itemCount == 0)
        {
            // Remove the items and add the new ones.
            items.remove();
            parent.append('...')
        }
    });
});

このようなだけで更新遅れます:

$(".item").each(function(i) {
    $(this).delay(200*i).animate({marginLeft:"0"}, 60);
});
ul li.item {
  margin-left: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
  <li class="item">List 1</li>
  <li class="item">List 2</li>
  <li class="item">List 3</li>
  <li class="item">List 4</li>
  <li class="item">List 5</li>
  <li class="item">List 6</li>
</ul>

@デビッド・ヘルシングのアルゴリズムに基づいて

私の貢献、

function pop_in(array_elem, index) {
    $(array_elem[index]).animate({
        width: 'toggle',
        height: 'toggle'
    }, 700)// callback will be a promise
    .promise()
    .then(() => {
        $(array_elem[index]).css({visibility: 'hidden'}); //hide after reduce size

        if(index > 0)
            pop_in(array_elem, --index) //recursive call
        else
            console.log("Animation finished. Execute another function from here.");
    });
}
const items_menu = $(".item");
pop_in(items_menu, items_menu.length-1); //start from last to first element

あなたがあなた自身の目的に幅と高さプロパティを変更することができます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top