OSDN Git Service

Version 0.6.132, fix X.Node._flags & fix X.EventDispatcher._listeners & start to...
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 14_XTimer.js
index 2ee2757..7846bf3 100644 (file)
@@ -67,6 +67,7 @@ var X_Timer_now = Date.now || function(){ return +new Date; },
        X_Timer_busyTimeout    = false,\r
        X_Timer_timeStamp      = 0, // setTimeout に登録した時間\r
        X_Timer_waitTime       = 0,     // 待ち時間\r
+       X_Timer_currentUID     = 0, // 現在発火中の uid\r
        \r
        X_Timer_REQ_FRAME_LIST = [],\r
        X_Timer_requestID      = 0,\r
@@ -113,7 +114,7 @@ X.Timer = {
                var list = X_Timer_TICKET_LIST,\r
                        i    = list.length,\r
                        l    = i,\r
-                       f, q;\r
+                       f, q, eventDispatcher, lazy, listeners;\r
                // fire 中の cancel\r
                if( X_Timer_busyTimeout ){\r
                        if( !X_Timer_removal ) X_Timer_removal = {};\r
@@ -122,6 +123,26 @@ X.Timer = {
                        for( ; i; ){\r
                                if( ( q = list[ --i ] ).uid === uid ){\r
                                        list.splice( i, 1 );\r
+                                       \r
+                                       /*\r
+                                        * lazyDispatch 中の EventDispatcher の有無を調べる\r
+                                        */\r
+                                       if( X_EventDispatcher_LAZY_TIMERS[ uid ] ){\r
+                                               eventDispatcher = X_EventDispatcher_LAZY_TIMERS[ uid ];\r
+                                               delete X_EventDispatcher_LAZY_TIMERS[ uid ];\r
+                                               /*\r
+                                               listeners = eventDispatcher[ '_listeners' ];\r
+                                               if( listeners && !listeners[ X_Listeners_.DISPATCHING ] && listeners[ X_Listeners_.KILL_RESERVED ] ){\r
+                                                       for( uid in X_EventDispatcher_LAZY_TIMERS ){\r
+                                                               if( X_EventDispatcher_LAZY_TIMERS[ uid ] === eventDispatcher ){\r
+                                                                       lazy = true;\r
+                                                                       break;\r
+                                                               };\r
+                                                       };                                              \r
+                                                       !lazy && eventDispatcher.kill();\r
+                                               }; */\r
+                                       };\r
+                                       \r
                                        !X_Timer_skipUpdate && ( q.last <= X_Timer_waitTime || l === 1 ) && X_Timer_update();\r
                                        break;\r
                                };\r
@@ -205,7 +226,7 @@ function X_Timer_onTimeout(){
                list  = X_Timer_TICKET_LIST,\r
                i     = 0,\r
                l     = list.length,\r
-               limit = X_Timer_now() + X_Timer_INTERVAL_TIME / 2,\r
+               limit = now + X_Timer_INTERVAL_TIME / 2,\r
                heavy,\r
                q, f, c, r, uid;\r
        \r
@@ -228,8 +249,9 @@ function X_Timer_onTimeout(){
                };\r
                c = q.count;\r
                \r
+               X_Timer_currentUID = q.uid;\r
+               \r
                if( q.k ){\r
-                       //q.a = [];\r
                        r = X_Callback_proxyCallback( q, [] );\r
                } else {\r
                        r = q.f();\r
@@ -252,12 +274,13 @@ function X_Timer_onTimeout(){
                if( 1 < c ) --q.count;\r
                q.last = q.time;\r
     };\r
-    X_Timer_timerId     = 0;\r
+    X_Timer_timerId     = X_Timer_currentUID = 0;\r
     X_Timer_busyTimeout = false;\r
     \r
     if( X_Timer_removal ){\r
        X_Timer_skipUpdate = true;\r
        for( uid in X_Timer_removal ){\r
+               //if( X_EMPTY_OBJECT[ uid ] ) continue;\r
                X.Timer.remove( uid );\r
        };\r
        X_Timer_skipUpdate = false;\r
@@ -304,9 +327,9 @@ if( X_UA.iOS ){
                var last, now;\r
                if( X_Timer_timerId ){\r
                        X_Timer_CLEAR_TIMEOUT( X_Timer_timerId );\r
-                       now  = X_Timer_now();\r
-                       last = X_Timer_timeStamp + X_Timer_INTERVAL_TIME * X_Timer_waitTime - now;\r
-                       X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 );\r
+                       now               = X_Timer_now();\r
+                       last              = X_Timer_timeStamp + X_Timer_INTERVAL_TIME * X_Timer_waitTime - now;\r
+                       X_Timer_timerId   = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 );\r
                        // 更新\r
                        X_Timer_timeStamp = now;\r
                        X_Timer_waitTime  = last / X_Timer_INTERVAL_TIME | 0;\r
@@ -344,6 +367,7 @@ function X_Timer_onEnterFrame( time ){
     X_Timer_busyOnFrame = false;\r
     if( X_Timer_removal ){\r
        for( uid in X_Timer_removal ){\r
+               //if( X_EMPTY_OBJECT[ uid ] ) continue;\r
                X.Timer.cancelFrame( X_Timer_removal[ uid ] );\r
        };\r
        X_Timer_removal = null;\r