OSDN Git Service

Version 0.6.180, fix X.Audio.
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 15_XEventDispatcher.js
index d6140a4..34a5933 100644 (file)
@@ -36,22 +36,30 @@ var X_LISTENERS_ACTUAL_HANDLER = 0,
 // ------------------------------------------------------------------------- //\r
 // ------------ local variables -------------------------------------------- //\r
 // ------------------------------------------------------------------------- //\r
-\r
-var X_EventDispatcher_once       = false,\r
-       X_EventDispatcher_lock       = false,\r
-       X_EventDispatcher_unlock     = false,\r
-       X_EventDispatcher_needsIndex = false,\r
-       \r
-       X_EventDispatcher_safariPreventDefault = false, // Safari3-\r
-       \r
-       /** @const */\r
+var /** @const */\r
        X_EventDispatcher_EVENT_TARGET_OTHER        = 0,\r
        /** @const */\r
        X_EventDispatcher_EVENT_TARGET_XHR          = 1,\r
        /** @const */\r
-       X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT = 2,\r
+       X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT = 2;\r
+\r
+var X_EventDispatcher_once         = false,\r
+       X_EventDispatcher_lock         = false,\r
+       X_EventDispatcher_unlock       = false,\r
+       X_EventDispatcher_needsIndex   = false,\r
        \r
-       X_EventDispatcher_LAZY_TIMERS = {}; // Object.<number, X.EventDispatcher> number は timerID\r
+       X_EventDispatcher_safariPreventDefault = false, // Safari3-\r
+\r
+       X_EventDispatcher_LAZY_TIMERS  = {},// Object.<number, X.EventDispatcher> number は timerID\r
+       \r
+       // iOS と MacOSX Iron36 で発生。連続してアニメーションが起こると、クロージャの束縛された obj へのアクセスに失敗する。Win では起きない?\r
+       // むしろ、MacOSX のブラウザ全般で起こる??\r
+       X_EventDispatcher_ANIME_EVENTS = ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) && {\r
+               'transitionend'      : true, 'webkitTransitionEnd'      : true, 'mozTransitionEnd'    : true, 'oTransitionEnd' : true, 'otransitionEnd' : true,\r
+               'animationend'       : true, 'webkitAnimationEnd'       : true, 'oAnimationEnd'       : true,\r
+               'animationstart'     : true, 'webkitAnimationStart'     : true, 'oAnimationStart'     : true,\r
+               'animationiteration' : true, 'webkitAnimationIteration' : true, 'oAnimationIteration' : true\r
+       };\r
 \r
 // ------------------------------------------------------------------------- //\r
 // --- interface ----------------------------------------------------------- //\r
@@ -524,6 +532,7 @@ function X_EventDispatcher_unlistenAll( that ){
 \r
 function X_EventDispatcher_actualAddEvent( that, type, raw, list ){\r
        var i, f;\r
+\r
        X_EventDispatcher_lock || ( type = X_Event_Rename[ type ] || type );\r
        \r
        if( X_Type_isArray( type ) ){\r
@@ -552,13 +561,7 @@ function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
                                        };\r
 \r
                                default :\r
-                                       // iOS と MacOSX Iron36 で発生。連続してアニメーションが起こると、クロージャの束縛された obj へのアクセスに失敗する。Win では起きない?\r
-                                       // むしろ、MacOSX のブラウザ全般で起こる??\r
-                                       if( ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) &&\r
-                                               ( type === 'webkitTransitionEnd' || type === 'transitionend' ||\r
-                                                 type === 'animationend'        || type === 'webkitAnimationEnd' ||\r
-                                                 type === 'animationstart'      || type === 'webkitAnimationStart' ||\r
-                                                 type === 'animationiteration'  || type === 'webkitAnimationIteration' ) ){\r
+                                       if( X_EventDispatcher_ANIME_EVENTS && X_EventDispatcher_ANIME_EVENTS[ type ] ){\r
                                                raw.addEventListener( type, X_EventDispatcher_iOSTransitionEndDispatch, false );\r
                                        } else {\r
                                                f = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Closure_create( that, X_EventDispatcher_actualHandleEvent ) );\r
@@ -637,6 +640,7 @@ function X_EventDispatcher_sliverLightDispatch( sender, e, type ){
 \r
 function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){\r
        var i;\r
+\r
        X_EventDispatcher_unlock || ( type = X_Event_Rename[ type ] || type );\r
        \r
        if( X_Type_isArray( type ) ){\r
@@ -662,13 +666,9 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
                                        };\r
 \r
                                default :\r
-                                       if( ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) &&\r
-                                               ( type === 'webkitTransitionEnd' || type === 'transitionend' ||\r
-                                                 type === 'animationend'        || type === 'webkitAnimationEnd' ||\r
-                                                 type === 'animationstart'      || type === 'webkitAnimationStart' ||\r
-                                                 type === 'animationiteration'  || type === 'webkitAnimationIteration' ) ){\r
+                                       if( X_EventDispatcher_ANIME_EVENTS && X_EventDispatcher_ANIME_EVENTS[ type ] ){\r
                                                raw.removeEventListener( type, X_EventDispatcher_iOSTransitionEndDispatch, false );\r
-                                       } else                  \r
+                                       } else\r
                                        if( raw.addEventListener ){\r
                                                raw.removeEventListener( type, that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ], false );\r
                                        } else {\r
@@ -741,6 +741,7 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
 \r
 \r
 // TODO ブラウザからの呼び出しの最後に登録された関数を呼び出す機能(例えば画面の更新)\r
+var X_EventDispatcher_CURRENT_EVENTS = [];\r
 \r
 // handleEvent を拡張可能にするために、クロージャに移動した\r
 // Is this in regard to the Safari 1.x preventDefault bug on click/dblclick?\r
@@ -748,9 +749,14 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
 var X_EventDispatcher_actualHandleEvent =\r
        X_UA_EVENT.IE4 || X_UA_EVENT.IE ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4\r
                (function(){\r
-                       var e = event, ret;\r
+                       var e  = event, ret,\r
+                               ev = new X_DomEvent( e, this, this[ '_rawObject' ] );\r
+                       \r
+                       X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length ] = ev;\r
                        \r
-                       ret = this[ 'dispatch' ]( new X_DomEvent( e, this, this[ '_rawObject' ] ) );\r
+                       ret = this[ 'dispatch' ]( ev );\r
+\r
+                       --X_EventDispatcher_CURRENT_EVENTS.length;\r
 \r
                        if( ret & X_CALLBACK_STOP_PROPAGATION ){\r
                                e.cancelBubble = true;\r
@@ -765,7 +771,9 @@ var X_EventDispatcher_actualHandleEvent =
                        var ev  = new X_DomEvent( e, this ),\r
                                ret = X_CALLBACK_NONE,\r
                                i, l;\r
-                       //console.log( '>>>>>>>>>> ' + e.type );\r
+                       \r
+                       X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length ] = ev;\r
+\r
                        // touch event -> pointer\r
                        if( X_Type_isArray( ev ) ){\r
                                if( ev.length === 0 ){\r
@@ -781,6 +789,8 @@ var X_EventDispatcher_actualHandleEvent =
                                ret = this[ 'dispatch' ]( ev );\r
                        };\r
                        \r
+                       --X_EventDispatcher_CURRENT_EVENTS.length;\r
+                       \r
                        if( ret & X_CALLBACK_STOP_PROPAGATION ){\r
                                e.stopPropagation();\r
                        };\r