2012-08-06 2 views
-1

현재이 (이미지) 페이드 아웃 기능이 종료 된 후 페이드 인 기능이 실행됩니다. crossfade 할 이미지와 각 이미지의 불투명도가 겹칠 필요가 있습니다. 나는이 일을하는 데 어려움을 겪고있다. 생각?동시에 js 함수를 호출합니다. yui

_initFade: function() { 
    this._timer = Y.later(this._intervalDuration, this, this._startPeriod, [], false); 

}, 

_startPeriod: function() { 
    this._timer = Y.later(this._intervalDuration, this, this._fadeOut, [], true); 
    this._fadeOut(); 
}, 

_fadeOut: function(){ 
    var host = this.get('host'); 
    this._animOut.set('node', host._getCurrentBlock()); 
    this._animOut.once('end', this._fadeIn, this); 
    this._animOut.run();  
}, 

_fadeIn: function(){ 
    var host = this.get('host'), 
     blocks = host.get('blocks'), 
     index = host.get('index'); 
     index = host._moveIndex(host._getNextIndex()); 

    var nextBlock = blocks.item(index); 
    this._transparent(nextBlock); 
    host.syncUI(); 
    this._animIn.set('node', nextBlock); 
    this._animIn.run(); 
}, 

답변

0

YUI는 동기화되어 실행되는 여러 애니메이션을 지원하지 않습니다. 그러나 Y.Anim의 '트윈'이벤트를 살펴보십시오. 애니메이션의 모든 프레임에 대해 호출됩니다. 따라서 애니메이션을 사용하여 하나의 이미지를 페이드 아웃시키고 트윈 이벤트 중에 두 번째 이미지의 불투명도를 조정할 수 있습니다.

예를 들어, 나는 동시에 여러 항목을 애니메이션 트윈 이벤트를 사용

var someNode = Y.Node.create("<div></div>"); // invisible div to animate 
Y.one(document.body).appendChild(someNode); 
var anim = new Y.Anim({ 
    node: someNode, 
    duration: 0.25, 
    from: { color: 'red' }, 
    to: { color: 'white' } 
}); 
anim.on('tween', function(event){ 
    Y.StyleSheet().set('input.text.error', { backgroundColor: someNode.getStyle('color') }); 
    // other animations 
}); 
+0

흥미 롭군요. 나는 완벽하게 싱크가되는 것에 대해 신경 쓰지 않는다. 동시에 두 애니메이션을 모두 쏘는 것이 가능하지 않을까? 비록 동기화되지 않더라도/ – ndreckshage

+0

물론, 'var anim1 = new Y.Anim(); anim2 = new Y.Anim(); anim1.run(); anim2.run(); ' Tween 이벤트를 사용하는 것만 큼 좋아 보이지 않을 것입니다. –