約束が.done()になると関数をループしようとしています。私は何かが欠けているようだ。ここに何か提案はありますか?jQueryは.promise()の後に関数をループする
私はこの機能を実行したいと最後のアニメーションが完了したら、もう一度やり直してください。
サポート機能を含め、ここにすべてのJSを含めています。
(function($) {
$.fn.shuffle = function() {
// credits: http://bost.ocks.org/mike/shuffle/
var m = this.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = this[m];
this[m] = this[i];
this[i] = t;
}
return this;
};
}(jQuery));
jQuery.noConflict();
jQuery(document).ready(function($) {
$.fn.queueAddClass = function(className) {
this.queue('fx', function(next) {
$(this).addClass(className);
next();
});
return this;
};
$.fn.animateGrid = function() {
$('.grid').shuffle().each(function(index) {
$(this).delay(100 * index).queueAddClass('zoom-down');
$('div', this).delay(100 * index).animate({opacity:0.85}, 100);
});
$('.grid').promise().done(function(){
$('.grid').animate({opacity:0}, 2000);
$('#mosaic').animateGrid();
});
}
$('#mosaic').animateGrid();
});
xyの問題です。単に、仕事に間違ったツールを置く。 https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=how%20to%20loop%20an%20animation%20in%20javascript –
正確には機能しません。 – Bergi
Btw、そのシャッフル機能は恐ろしいです。 jQueryコレクション内の要素は、常にDOMツリーの順序になっている必要があります。 – Bergi