2011-11-16 19 views
0

Mootoolsでは、一度に1つのdivのグループをフェードインしたいと思います。基本的には、それぞれの繰り返しごとに遅延を追加したいと考えています。each of()の繰り返しの間の遅延

$$('.someclass').each(function(el){ 
     el.set('tween', { 
     duration: 1000 
     }); 
     el.tween('opacity',0,1); 
    }); 

答えて

2

またはあなただけ行うことができます....

document.getElements('.someclass').each(function(el, index) { 
    el.set('tween', { 
     duration: 1000 
    }).fade.delay(index * 1000, el, [0, 1]); 
}); 

この最初の1の後に連続した各フェード1秒を開始します。

テスト

および1.3.2での作業:原因method overloading to the Fx.Tween instance being removedhttp://jsfiddle.net/dimitar/jMdbR/1/ - あなたが開始する前に、不透明度を設定することによって、それを回避することができますが - または.tweenを使用して::http://jsfiddle.net/dimitar/jMdbR/

は1.4.1で壊れているようだ

document.getElements('.someclass').each(function(el, index) { 
    el.set('tween', { 
     duration: 1000 
    }).tween.delay(index * 1000, el, ["opacity", [0, 1]]); 
}); 

http://jsfiddle.net/dimitar/jMdbR/4/ for tweenで動作します。

0

これは機能的な反復ループで行うことができます。

var divs = $$(".someclass"); // Assuming this object is Array-like 

var iterator = function (elements, i) { 
    if (!elements.hasOwnProperty(i)) return; 

    var element = elements[i++]; 
    element.set("tween", {duration: 1000}); 
    element.tween("opacity", 0, 1); 

    // Note: not sure if this is the actual API to get notified when 
    // the animation completes. But this illustrates my point. 
    element.set("events", {complete: function() { 
     iterator(elements, i); 
    }}); 
} 

iterator(divs, 0); 

考えるとMooToolsのは、アニメーションが終了したとき、あなたは更新iカウンターで再帰的にイテレータ関数を呼び出すためにそれを使用することができます通知を得るためのAPIを提供します。

関連する問題