X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F10_XNodeAnime.js;h=0b5a8a8d64c54651e085434134f0942118354dad;hb=6c4c72f7e862c9f950bfb3562adda24c39498abd;hp=463080a4aa3a0ab399eb14d704abe6159cd4d7b5;hpb=7d3b5c3962eea3585a009bfc290a71560b2e83b3;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/02_dom/10_XNodeAnime.js b/0.6.x/js/02_dom/10_XNodeAnime.js index 463080a..0b5a8a8 100644 --- a/0.6.x/js/02_dom/10_XNodeAnime.js +++ b/0.6.x/js/02_dom/10_XNodeAnime.js @@ -61,17 +61,18 @@ var X_Node_ANIMATIONS = [], X_Node_Anime_reserved = false, X_Node_Anime_updateTimerID = 0, X_Node_Anime_needsDetection = false, + X_Node_Anime_onTransition = false, + X_Node_Anime_hasTransform = !!X_Node_CSS_VENDER_PREFIX[ 'transform' ], /* Opera mobile で translateZ(0) が有効だと XY が 0 0 になる */ /* GPUレイヤーにいる間に要素のコンテンツを変更をすると transitionend が動かなくなるっぽい Mac safari と firefox, 手当てが済むまでここは常に false */ - X_Node_Anime_translateZ = X_Node_CSS_VENDER_PREFIX[ 'perspective' ] && !X_UA.OperaMobile && !X_UA.OperaTablet ? ' translateZ(0)' : '', + X_Node_Anime_translateZ = X_Node_CSS_VENDER_PREFIX[ 'perspective' ] && !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] ? ' translateZ(0)' : '', /* Opera12(XP,8.1) 切った方がスムース, win Safari3 で、たまに動作が止まってしまう、、、 */ - X_Node_Anime_hasTransition = !!X_Node_CSS_VENDER_PREFIX[ 'transitionDelay' ] && !X_UA.Opera && !( X_UA.Webkit <= 528.16 ), + X_Node_Anime_hasTransition = !!X_Node_CSS_VENDER_PREFIX[ 'transitionDelay' ] && !X_UA[ 'Opera' ], // && !( X_UA[ 'Webkit' ] <= 528.16 ), X_Node_Anime_transitionProps = X_Node_Anime_hasTransform ? X_Node_CSS_VENDER_PREFIX[ 'transform' ] : 'left,top', // transitionEnd イベント中に要素の更新( X_Node_startUpdate() )ができるか? // iOS3+4 では可能、iOS6.1.5 で不可。TODO iOS5 及び他の環境で調査。ダメな場合、anime.html が正しく描画されない。 - X_Node_updateOnTransitionEnd = X_UA.iOS < 6, - X_Node_Anime_onTransition = false; + X_Node_updateOnTransitionEnd = false; //X_UA[ 'iOS' ] < 6; // gpu化だけ transformX , willChange // 終了位置の変更 @@ -84,17 +85,18 @@ var X_Node_ANIMATIONS = [], * TODO : skew * TODO : filter * TODO 前回位置からの継続 + * TODO scrollLeft, scrollTop */ -Node.prototype.animate = function( start, dest, duration, easing, wait ){ - var isNew = !this._anime, - obj = this._anime || ( this._anime = {} ); +Node.prototype[ 'animate' ] = function( start, dest, duration, easing, wait ){ + var isNew = !this[ '_anime' ], + obj = this[ '_anime' ] || ( this[ '_anime' ] = {} ); - obj.duration = 0 <= duration && X.Type.isFinite( duration ) ? duration : 500; + obj.duration = 0 <= duration && X_Type_isFinite( duration ) ? duration : 500; obj.easing = ease[ easing ] || ease.circular; // 現在 GPUレイヤーのtop になっているか?将来については phase で判定 obj.gpuParent = obj.gpuParent || false; obj.phase = duration === 0 ? 9 : obj.phase === 9 ? 9 : 0; // - obj.wait = X.Type.isFinite( wait ) ? wait : 1000; + obj.wait = X_Type_isFinite( wait ) ? wait : 1000; obj.startTime = X_Timer_now(); obj.startX = ( start.x || start.x === 0 ) ? start.x : obj.x || 0; @@ -115,7 +117,7 @@ Node.prototype.animate = function( start, dest, duration, easing, wait ){ if( X_Node_Anime_hasTransition ){ if( obj.gpuTimerID ){ - X.Timer.remove( obj.gpuTimerID ); + X_Timer_remove( obj.gpuTimerID ); delete obj.gpuTimerID; }; @@ -123,28 +125,39 @@ Node.prototype.animate = function( start, dest, duration, easing, wait ){ X_Node_Anime_reserveUpdate( true ); } else { - X_System.unlisten( X.Event.UPDATED, X_Node_Anime_updateAnimationsNoTransition ); - X_Node_Anime_updateTimerID || ( X_Node_Anime_updateTimerID = X.Timer.requestFrame( X_Node_Anime_updateAnimationsNoTransition ) ); + if( !X_Node_Anime_reserved ){ + X_Node_Anime_reserved = true; + if( X_Node_updateTimerID ){ + X_System[ 'listen' ]( X_EVENT_UPDATED, X_Node_Anime_updateAnimationsNoTransition ); + X_Node_Anime_updateTimerID && X_Timer_cancelFrame( X_Node_Anime_updateTimerID ); + X_Node_Anime_updateTimerID = 0; + } else { + X_System[ 'unlisten' ]( X_EVENT_UPDATED, X_Node_Anime_updateAnimationsNoTransition ); + X_Node_Anime_updateTimerID = X_Timer_requestFrame( X_Node_Anime_updateAnimationsNoTransition ); + }; + }; - isNew && this.dispatch( { type : X.Event.ANIME_START, gpu : false } ); + isNew && this[ 'dispatch' ]( { type : X_EVENT_ANIME_START, 'gpu' : false } ); }; - console.log( 'animate ' + this._id + ' y:' + obj.startX + ' > ' + obj.destX + ' d:' + obj.duration ); + // console.log( 'animate() ' + this[ '_id' ] + ' y:' + obj.startY + ' > ' + obj.destY + ' d:' + obj.duration ); return this; }; -Node.prototype.stop = function(){ - var obj = this._anime; - if( !obj ) return; +Node.prototype[ 'stop' ] = function(){ + var obj = this[ '_anime' ]; + + if( !obj ) return this; + if( X_Node_Anime_hasTransition ){ obj.phase = 100; X_Node_Anime_needsDetection = true; X_Node_Anime_reserveUpdate(); } else { X_Node_ANIMATIONS.splice( X_Node_ANIMATIONS.indexOf( this ), 1 ); - //obj.gpuTimerID && X.Timer.remove( obj.gpuTimerID ); - delete this._anime; + //obj.gpuTimerID && X_Timer_remove( obj.gpuTimerID ); + delete this[ '_anime' ]; }; return this; }; @@ -154,24 +167,26 @@ function X_Node_Anime_reserveUpdate( before ){ X_Node_Anime_reserved = true; if( X_Node_updateTimerID ){ - console.log( before ? '> BEFORE_UPDATE' : '> UPDATED' ); + //console.log( before ? '> BEFORE_UPDATE' : '> UPDATED' ); before = false; - X_System.listenOnce( before ? X.Event.BEFORE_UPDATE : X.Event.UPDATED, X_Node_Anime_updateAnimations ); + X_System[ 'listenOnce' ]( before ? X_EVENT_BEFORE_UPDATE : X_EVENT_UPDATED, X_Node_Anime_updateAnimations ); } else { - console.log( '> Timer' ); + //console.log( '> Timer' ); // Opera12 requestAnimationFrame では transition が動かない、、、 X_Node_Anime_updateTimerID = - X_UA.Opera ? - X.Timer.once( 0, X_Node_Anime_updateAnimations ) : - X.Timer.requestFrame( X_Node_Anime_updateAnimations ); + X_UA[ 'Opera' ] ? + X_Timer_once( 0, X_Node_Anime_updateAnimations ) : + X_Timer_requestFrame( X_Node_Anime_updateAnimations ); }; + } else { + // console.log( ' X_Node_Anime_reserved 済、予約なし' ); }; }; function X_Node_Anime_updateAnimations( v, updateNow ){ - var i = X_Node_ANIMATIONS.length, ret, c = false; + var i = X_Node_ANIMATIONS.length, c = false, ret, xnode; - //console.log( v.type || v ); + // console.log( v.type || v ); //console.log( 'updateAnimations len:' + i + ' time:' + v + ' det:' + X_Node_Anime_needsDetection ); @@ -179,12 +194,12 @@ function X_Node_Anime_updateAnimations( v, updateNow ){ for( ; i; ){ xnode = X_Node_ANIMATIONS[ --i ]; - //console.log( 'phase : ' + xnode._id + ' ' + xnode._anime.phase + ' ' + xnode._anime.duration ); + //console.log( 'phase : ' + xnode[ '_id' ] + ' ' + xnode[ '_anime' ].phase + ' ' + xnode[ '_anime' ].duration ); ret = X_Node_Anime_updateAnimation( xnode ); if( ret === true ){ X_Node_ANIMATIONS.splice( i, 1 ); - xnode._anime.gpuTimerID && X.Timer.remove( xnode._anime.gpuTimerID ); - delete xnode._anime; + xnode[ '_anime' ].gpuTimerID && X_Timer_remove( xnode[ '_anime' ].gpuTimerID ); + delete xnode[ '_anime' ]; } else if( ret !== false ){ c = true; @@ -200,7 +215,7 @@ function X_Node_Anime_updateAnimations( v, updateNow ){ }; }; -// TODO X.Timer.requestFrame 経由の BEFORE_UPDATE で更新を行う +// TODO X_Timer_requestFrame 経由の BEFORE_UPDATE で更新を行う function X_Node_Anime_detectAnimationLayers(){ var i = X_Node_ANIMATIONS.length, l = i, @@ -215,44 +230,44 @@ function X_Node_Anime_detectAnimationLayers(){ if( xnode.parent === _xnode.parent ){ continue; } else - if( _xnode.contains( xnode ) ){ - if( ( _xnode._anime.phase === 3 && _xnode._anime.gpuParent ) || _xnode._anime.phase === 10 ){ - _xnode._anime.phase = 15; + if( _xnode[ 'contains' ]( xnode ) ){ + if( ( _xnode[ '_anime' ].phase === 3 && _xnode[ '_anime' ].gpuParent ) || _xnode[ '_anime' ].phase === 10 ){ + _xnode[ '_anime' ].phase = 15; } else - if( xnode._anime.gpuParent ){ + if( xnode[ '_anime' ].gpuParent ){ parent = true; - xnode._anime.phase = xnode._anime.phase === 2 ? 6 : 15;// GPU レイヤーの解除 > アニメーションは継続, すでに終了フェイズなら破棄 + xnode[ '_anime' ].phase = xnode[ '_anime' ].phase === 2 ? 6 : 15;// GPU レイヤーの解除 > アニメーションは継続, すでに終了フェイズなら破棄 } else - if( [ 7, 8, 9, 13, 14 ].indexOf( xnode._anime.phase ) !== -1 ){// GPU レイヤーの中止 + if( [ 7, 8, 9, 13, 14 ].indexOf( xnode[ '_anime' ].phase ) !== -1 ){// GPU レイヤーの中止 parent = true; - xnode._anime.phase -= 8; + xnode[ '_anime' ].phase -= 8; }; break; } else - if( xnode.contains( _xnode ) ){ - if( ( xnode._anime.phase === 3 && xnode._anime.gpuParent ) || xnode._anime.phase === 10 ){ - xnode._anime.phase = 15; + if( xnode[ 'contains' ]( _xnode ) ){ + if( ( xnode[ '_anime' ].phase === 3 && xnode[ '_anime' ].gpuParent ) || xnode[ '_anime' ].phase === 10 ){ + xnode[ '_anime' ].phase = 15; } else - if( _xnode._anime.gpuParent ){ + if( _xnode[ '_anime' ].gpuParent ){ hasGPUChild = true; - _xnode._anime.phase = _xnode._anime.phase === 2 ? 6 : 15;// GPU レイヤーの解除 > アニメーションは継続, すでに終了フェイズなら破棄 + _xnode[ '_anime' ].phase = _xnode[ '_anime' ].phase === 2 ? 6 : 15;// GPU レイヤーの解除 > アニメーションは継続, すでに終了フェイズなら破棄 } else - if( [ 7, 8, 9, 13, 14 ].indexOf( _xnode._anime.phase ) !== -1 ){// GPU レイヤーの中止 + if( [ 7, 8, 9, 13, 14 ].indexOf( _xnode[ '_anime' ].phase ) !== -1 ){// GPU レイヤーの中止 hasGPUChild = true; - _xnode._anime.phase -= 8; + _xnode[ '_anime' ].phase -= 8; }; break; }; }; - if( !parent && xnode._anime.phase !== 15 ){ - if( xnode._anime.phase === 0 ){ + if( !parent && xnode[ '_anime' ].phase !== 15 ){ + if( xnode[ '_anime' ].phase === 0 ){ // 新規 - xnode._anime.phase = hasGPUChild ? 7 : 8;// 非GPU -> GPU 子に GPU アニメをもつなら、タイミングをずらす。 + xnode[ '_anime' ].phase = hasGPUChild ? 7 : 8;// 非GPU -> GPU 子に GPU アニメをもつなら、タイミングをずらす。 } else - if( [ 3, 4, 10, 100 ].indexOf( xnode._anime.phase ) === -1 ){ + if( [ 3, 4, 10, 100 ].indexOf( xnode[ '_anime' ].phase ) === -1 ){ // 非GPU -> GPU - xnode._anime.phase = hasGPUChild ? 13 : 14;// 非GPU -> GPU 子に GPU アニメをもつなら、タイミングをずらす。 + xnode[ '_anime' ].phase = hasGPUChild ? 13 : 14;// 非GPU -> GPU 子に GPU アニメをもつなら、タイミングをずらす。 }; }; }; @@ -264,7 +279,7 @@ function X_Node_Anime_detectAnimationLayers(){ * 0:無, 1:子のGPU解除待 2:GPU予約, 3:GPU now!, 4:GPU解除予約 */ function X_Node_Anime_updateAnimation( xnode ){ - var obj = xnode._anime, + var obj = xnode[ '_anime' ], phase = obj.phase, current, time; switch( phase ){ @@ -278,45 +293,48 @@ function X_Node_Anime_updateAnimation( xnode ){ break; case 0 : // 開始位置+アニメーションの設定 case 8 : - X_ViewPort.unlisten( X.Event.AFTER_UPDATE, xnode, X_Node_Anime_gpuReleased ); + X_ViewPort[ 'unlisten' ]( X_EVENT_AFTER_UPDATE, xnode, X_Node_Anime_gpuReleased ); - xnode.css({ + xnode[ 'css' ]({ //willChange : X_Node_Anime_transitionProps + ',opacity,width,height', backfaceVisibility : 'hidden', transitionTimingFunction : obj.easing.style, transitionDelay : '0s' // 0.001 にすると transitionend のタイミングが狂う、、、 }); - console.log( '開始位置 ' + phase ); + //console.log( '開始位置 ' + phase ); X_Node_Anime_updatePosition( xnode, obj.startX, obj.startY, obj.startA, phase === 8 ); - xnode.dispatch( { type : X.Event.ANIME_START, gpu : phase === 8 } ); + xnode[ 'dispatch' ]( { type : X_EVENT_ANIME_START, 'gpu' : phase === 8 } ); ++obj.phase; break; case 1 : case 9 : // 終了位置の設定 obj.gpuParent = phase === 9; if( obj.duration ){ - xnode.listenOnce( 'transitionend', X_Node_Anime_onTransitionEnd ); + xnode[ 'listenOnce' ]( 'transitionend', X_Node_Anime_onTransitionEnd ); - xnode.css({ - transitionProperty : X_Node_Anime_transitionProps + ',opacity,width,height', // X_Node_Anime_readyTransitionに移動?? + xnode[ 'css' ]({ + transitionProperty : X_Node_Anime_transitionProps + ',opacity,width,height', transitionDuration : obj.duration + 'ms' }); - console.log( '修了位置 ' + phase ); + //console.log( '修了位置 ' + phase ); X_Node_Anime_updatePosition( xnode, obj.destX, obj.destY, obj.destA, obj.gpuParent ); obj.phase = 2; break; }; - console.log( 'duration = 0 の場合、アニメーションの解除' ); + //console.log( 'duration = 0 の場合、アニメーションの解除' ); // duration = 0 の場合、アニメーションの解除 case 3 : // アニメーションの解除 obj.phase = obj.gpuParent ? 10 : 4; + + console.log( '#### アニメーションの解除 ' + obj.phase ); + // このタイミングで animation 関連の css を削除したところ(X_Node_Anime_clearTransition)、iOS3、4 で再描画忘れが度々起きるように、、、 if( !obj.gpuParent ) X_Node_Anime_clearTransition( xnode ); - xnode.dispatch( { type : X.Event.ANIME_END, gpu : obj.gpuParent } ); + //xnode[ 'dispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : obj.gpuParent } ); break; case 4 : @@ -326,10 +344,11 @@ function X_Node_Anime_updateAnimation( xnode ){ case 10 : // アニメーションは停止・GPUレイヤーは解除していない(再アニメーションに備えて待機) - X_Node_Anime_clearTransition( xnode ); // TODO X_Node_Anime_releaseGPULayer に移動? + //X_Node_Anime_clearTransition( xnode ); // TODO X_Node_Anime_releaseGPULayer に移動? if( !obj.gpuTimerID ){ + console.log( '#### アニメーションは停止 ' + obj.wait ); if( obj.wait ){ - obj.gpuTimerID = X.Timer.once( obj.wait, xnode, X_Node_Anime_releaseGPULayer ); + obj.gpuTimerID = X_Timer_once( obj.wait, xnode, X_Node_Anime_releaseGPULayer ); } else { X_Node_Anime_releaseGPULayer.call( xnode ); }; @@ -351,7 +370,7 @@ function X_Node_Anime_updateAnimation( xnode ){ X_Node_Anime_clearTransition( xnode ); X_Node_Anime_updatePosition( xnode, obj.destX, obj.destY, obj.destA, phase === 14 ); obj.phase = phase === 14 ? 10 : 4; - xnode.dispatch( { type : X.Event.ANIME_END, gpu : obj.gpuParent } ); + xnode[ 'asyncDispatch' ]( time, { type : X_EVENT_ANIME_END, 'gpu' : obj.gpuParent } ); } else { current = X_Node_Anime_getComputedPosition( xnode ); obj.startX = current.x; @@ -366,17 +385,18 @@ function X_Node_Anime_updateAnimation( xnode ){ case 15 : // GPU有効で停止(待機)している xnode の解除 - //console.log( 'GPU有効で停止(待機)している xnode の解除' + xnode._tag + xnode.getOrder() ); - console.log( 'GPU有効で停止(待機)している xnode のGPU解除' ); + //console.log( 'GPU有効で停止(待機)している xnode の解除' + xnode[ '_tag' ] + xnode[ 'getOrder' ]() ); + // console.log( 'GPU有効で停止(待機)している xnode のGPU解除' ); X_Node_Anime_clearTransition( xnode ); X_Node_Anime_updatePosition( xnode, obj.destX, obj.destY, obj.destA, false ); - obj.gpuTimerID && X.Timer.remove( obj.gpuTimerID ); - X_ViewPort.listenOnce( X.Event.AFTER_UPDATE, xnode, X_Node_Anime_gpuReleased ); + //obj.gpuTimerID && X_Timer_remove( obj.gpuTimerID ); + //delete obj.gpuTimerID; + X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, xnode, X_Node_Anime_gpuReleased ); return true; case 100 : // stop() : アニメーションを中断して削除 //console.log( 'stop() gpu:' + obj.gpuParent ); - console.log( 'アニメーションを中断して削除' ); + // console.log( 'アニメーションを中断して削除' ); current = X_Node_Anime_getComputedPosition( xnode ); X_Node_Anime_clearTransition( xnode ); @@ -388,7 +408,7 @@ function X_Node_Anime_updateAnimation( xnode ){ }; function X_Node_Anime_getComputedPosition( that ) { - var matrix = X_node_CSS_getComputedStyle( that._rawObject, null ), + var matrix = X_Node_CSS_getComputedStyle( that[ '_rawObject' ], null ), x, y; if ( X_Node_Anime_hasTransform ) { @@ -404,13 +424,20 @@ function X_Node_Anime_getComputedPosition( that ) { }; function X_Node_Anime_onTransitionEnd( e ){ - if( !this._anime || this._anime.phase !== 2 ) return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION; - this._anime.phase = 3; + console.log( '[TransitionEnd] ' + ( this[ '_anime' ] && this[ '_anime' ].phase ) ); + + if( !this[ '_anime' ] || this[ '_anime' ].phase !== 2 ){ + // ここで return してしまうと、view の更新イベント待ちの場合、アニメが止まる + X_Node_Anime_reserved && !X_Node_Anime_updateTimerID && !X_Node_updateTimerID && X_Node_Anime_reserveUpdate( X_Node_Anime_reserved = false ); + return X_Callback_PREVENT_DEFAULT | X_Callback_STOP_PROPAGATION; + }; + + this[ '_anime' ].phase = 3; - console.log( 'トランジション終了' ); + X_Node_Anime_clearTransition( this ); // X_EVENT_ANIME_END より前で呼んでおく X_Node_Anime_onTransition = true; - this.dispatch( { type : X.Event.ANIME_END, gpu : this._anime.gpuParent } ); + this[ 'dispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : this[ '_anime' ].gpuParent } ); X_Node_Anime_onTransition = false; X_Node_Anime_needsDetection = true; @@ -418,36 +445,37 @@ function X_Node_Anime_onTransitionEnd( e ){ // win+Gecko は不可 X_Node_Anime_updateAnimations( 0, X_Node_updateOnTransitionEnd ); - return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION; + return X_Callback_PREVENT_DEFAULT | X_Callback_STOP_PROPAGATION; }; function X_Node_Anime_releaseGPULayer(){ - var obj = this._anime, tmp; + var obj = this[ '_anime' ], tmp; if( !obj ){ - console.log( '_anime無' ); + // console.log( '_anime無' ); return; }; + X_Node_Anime_clearTransition( this ); X_Node_Anime_updatePosition( this, obj.destX, obj.destY, obj.destA, false ); X_Node_ANIMATIONS.splice( X_Node_ANIMATIONS.indexOf( this ), 1 ); delete obj.gpuTimerID; - delete this._anime; + delete this[ '_anime' ]; console.log( 'GPUレイヤーの破棄を指示' ); - X_ViewPort.listenOnce( X.Event.AFTER_UPDATE, this, X_Node_Anime_gpuReleased ); + X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, X_Node_Anime_gpuReleased ); }; function X_Node_Anime_gpuReleased(){ - console.log( 'GPU レイヤーが解放されました' ); - this.dispatch( { type : X.Event.GPU_RELEASED, gpu : true } ); + //console.log( 'GPU レイヤーが解放されました' ); + this[ 'dispatch' ]( { type : X_EVENT_GPU_RELEASED, 'gpu' : true } ); }; function X_Node_Anime_clearTransition( xnode ){ // 開始座標のセット(新規のみ) // アニメーション指定のセット(または解除)(対象のみ) // 目標座標のセット - //xnode.unlisten( 'transitionend', X_Node_Anime_onTransitionEnd ); + xnode[ 'unlisten' ]( 'transitionend', X_Node_Anime_onTransitionEnd ); - xnode.css({ + xnode[ 'css' ]({ //willChange : '', backfaceVisibility : '', transitionTimingFunction : '', @@ -457,42 +485,44 @@ function X_Node_Anime_clearTransition( xnode ){ }; function X_Node_Anime_updatePosition( xnode, x, y, opacity, useGPU ){ - //console.log( 'y : ' + y + ' gpu : ' + !!useGPU ); + console.log( 'updatePosition x:' + x + ' gpu:' + !!useGPU ); if( X_Node_Anime_hasTransform ){ - xnode.css({ + xnode[ 'css' ]({ transform : 'translate(' + ( x | 0 ) + 'px,' + ( y | 0 ) + 'px)' + ( useGPU ? X_Node_Anime_translateZ : '' ), opacity : opacity }); } else { - xnode.css({ + xnode[ 'css' ]({ left : ( x | 0 ) + 'px', top : ( y | 0 ) + 'px', opacity : opacity }); }; - if( useGPU ){ - if( xnode._flags & X_Node_State.GPU_RELEASE_RESERVED ){ - xnode._flags &= X_Node_BitMask_RESET_GPU; - xnode._flags |= X_Node_State.GPU_NOW; - } else - if( xnode._flags & X_Node_State.GPU_NOW ){ + if( X_Node_Anime_translateZ ){ + if( useGPU ){ + if( xnode[ '_flags' ] & X_Node_State.GPU_RELEASE_RESERVED ){ + xnode[ '_flags' ] &= X_Node_BitMask_RESET_GPU; + xnode[ '_flags' ] |= X_Node_State.GPU_NOW; + } else + if( xnode[ '_flags' ] & X_Node_State.GPU_NOW ){ + } else { + xnode[ '_flags' ] &= X_Node_BitMask_RESET_GPU; + xnode[ '_flags' ] |= X_Node_State.GPU_RESERVED; + }; } else { - xnode._flags &= X_Node_BitMask_RESET_GPU; - xnode._flags |= X_Node_State.GPU_RESERVED; - }; - } else { - if( xnode._flags & X_Node_State.GPU_NOW ){ - xnode._flags &= X_Node_BitMask_RESET_GPU; - xnode._flags |= X_Node_State.GPU_RELEASE_RESERVED; - } else - if( xnode._flags & X_Node_State.GPU_RESERVED ){ - xnode._flags &= X_Node_BitMask_RESET_GPU; - }; + if( xnode[ '_flags' ] & X_Node_State.GPU_NOW ){ + xnode[ '_flags' ] &= X_Node_BitMask_RESET_GPU; + xnode[ '_flags' ] |= X_Node_State.GPU_RELEASE_RESERVED; + } else + if( xnode[ '_flags' ] & X_Node_State.GPU_RESERVED ){ + xnode[ '_flags' ] &= X_Node_BitMask_RESET_GPU; + }; + }; }; }; -function X_Node_Anime_updateAnimationsNoTransition(){ +function X_Node_Anime_updateAnimationsNoTransition( e ){ var i = X_Node_ANIMATIONS.length, now = X_Timer_now(), obj, @@ -501,16 +531,16 @@ function X_Node_Anime_updateAnimationsNoTransition(){ for( ; i; ){ xnode = X_Node_ANIMATIONS[ --i ]; - obj = xnode._anime; + obj = xnode[ '_anime' ]; if( obj.destTime <= now ){ X_Node_Anime_updatePosition( xnode, obj.destX, obj.destY, obj.destA, false ); - delete xnode._anime; + delete xnode[ '_anime' ]; X_Node_ANIMATIONS.splice( i, 1 ); // filter な 親が解除されないと子要素への filter が反映されない - xnode.asyncDispatch( { type : X.Event.ANIME_END, gpu : false } ); + xnode[ 'asyncDispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : false } ); } else { easing = obj.easing.fn( ( now - obj.startTime ) / obj.duration ); newX = ( obj.destX - obj.startX ) * easing + obj.startX; @@ -524,14 +554,21 @@ function X_Node_Anime_updateAnimationsNoTransition(){ }; }; - if( c ){ + c && console.log( 'anime... ' + X_Node_updateTimerID ); + + if( X_Node_Anime_reserved = c ){ if( X_Node_updateTimerID ){ - X_System.listen( X.Event.UPDATED, X_Node_Anime_updateAnimationsNoTransition ); + // scrollbox では X_System X_EVENT_UPDATED は不可。。。 + !e || e.type !== X_EVENT_UPDATED ? + X_System[ 'listen' ]( X_EVENT_UPDATED, X_Node_Anime_updateAnimationsNoTransition ) : + X_Node_Anime_updateTimerID && X_Timer_cancelFrame( X_Node_Anime_updateTimerID ); X_Node_Anime_updateTimerID = 0; } else { - X_Node_Anime_updateTimerID = X.Timer.requestFrame( X_Node_Anime_updateAnimationsNoTransition ); + X_System[ 'unlisten' ]( X_EVENT_UPDATED, X_Node_Anime_updateAnimationsNoTransition ); + X_Node_Anime_updateTimerID = X_Timer_requestFrame( X_Node_Anime_updateAnimationsNoTransition ); }; } else { + X_System[ 'unlisten' ]( X_EVENT_UPDATED, X_Node_Anime_updateAnimationsNoTransition ); X_Node_Anime_updateTimerID = 0; }; };