OSDN Git Service

Version 0.6.193, bug fixes X.Node.Anime.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 20_Root.js
index 6339c63..5c301e0 100644 (file)
@@ -1,37 +1,81 @@
-var XUI_rootData        = null,
-       XUI_xnodeIneraction = null,
-       XUI_UINODES_HOVER   = [],
-       XUI_EVENT_COUNTER   = {},
-       XUI_uinodeTarget    = null,
+var XUI_rootData         = null,
+       XUI_xnodeIneraction  = null,
+       XUI_mousemoveFix     = X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ],
+       XUI_mousemoveFixOn   = 0,
+       XUI_mousemoveFixX    = 0,
+       XUI_mousemoveFixY    = 0,
+       XUI_mousemoveFixLast = null,
+       XUI_UINODES_HOVER    = [],
+       XUI_EVENT_COUNTER    = {},
+       XUI_uinodeTarget     = null,
        XUI_xnodeInteractionOverlay,
-       XUI_interactionBusy = false;
+       XUI_interactionBusy  = false;
+
+function XUI_mousemoveFixResetScroll(){
+       var raw = XUI_xnodeInteractionOverlay[ '_rawObject' ];
+
+       if( XUI_mousemoveFix ){
+               XUI_mousemoveFixX = raw.scrollLeft = raw.offsetWidth;
+               XUI_mousemoveFixY = raw.scrollTop  = raw.offsetHeight;          
+       };
+};
+
+function XUI_mousemoveFixScrollEnd(){
+       var raw  = XUI_xnodeInteractionOverlay[ '_rawObject' ];
+
+       XUI_mousemoveFixOn = 0;
+       XUI_mousemoveFixLast.type = 'pointerup';
+       X_UI_eventRellay( XUI_mousemoveFixLast );
+       
+       raw.scrollLeft = XUI_mousemoveFixX;
+       raw.scrollTop  = XUI_mousemoveFixY;
+};
 
 function X_UI_eventRellay( e ){
        var font    = X_ViewPort_baseFontSize,
-               x       = e.pageX / font, // clientX は iOS4- で通らない?
-               y       = e.pageY / font,
+               x       = e.pageX, // clientX は iOS4- で通らない?
+               y       = e.pageY,
                type    = XUI_Event.NameToID[ e.type ],
                i       = 0,
                data    = XUI_rootData,
                sysOnly = false,
                ret     = X_CALLBACK_NONE,
-               list, parent, _ret, eventIn, eventOut;
+               list    = XUI_UINODES_HOVER,
+               raw, parent, _ret, eventIn, eventOut;
 
-       // mouseup で alert を出すと mouseleave が発生、ということでイベント中のイベント発火を禁止
-       if( !data || XUI_interactionBusy ) return ret;
+       // mouseup で alert を出すと mouseleave が発生、ということでイベント中のイベント発火を禁止
+       if( XUI_interactionBusy ) return ret;
        
        XUI_interactionBusy = true;
 
+       if( XUI_mousemoveFix ){
+               if( e.type === 'scroll' ){
+                       raw  = XUI_xnodeInteractionOverlay[ '_rawObject' ];
+                       type = XUI_mousemoveFixOn ? XUI_Event._POINTER_MOVE : XUI_Event._POINTER_DOWN;
+                       x    = XUI_mousemoveFixX - raw.scrollLeft;
+                       y    = XUI_mousemoveFixY - raw.scrollTop;
+                       e.pageX = x;
+                       e.pageY = y;
+                       e[ 'button' ]      = 0;
+                       e[ 'timestamp' ]   = e[ 'timeStamp' ];
+                       e[ 'pointerId' ]   = 1;
+                       e[ 'pointerType' ] = 'mouse';
+
+                       XUI_mousemoveFixOn && X_Timer_remove( XUI_mousemoveFixOn );
+                       XUI_mousemoveFixOn   = X_Timer_once( 250, XUI_mousemoveFixScrollEnd );
+                       XUI_mousemoveFixLast = X_Object_copy( e );
+               };
+       };
+
        e = X_Object_copy( e );
        e.type = type;
 
-       // TODO capture は pointer 毎に!
-       list = XUI_UINODES_HOVER;
-       ( XUI_uinodeTarget = XUI_rootData ).capcher( x, y );
-       data = XUI_uinodeTarget;
+       // capture は pointer 毎に!
+       data.capcher( x / font, y / font );
+       data = XUI_uinodeTarget || data;
 
        while( data ){
-               _ret = data[ 'dispatch' ]( e, sysOnly );
+               _ret = data[ 'dispatch' ]( e, sysOnly ) || X_CALLBACK_NONE;
                ret |= _ret;
                if( type < XUI_Event._START_BUBLEUP || ret & X_CALLBACK_STOP_PROPAGATION ){
                        break;
@@ -114,17 +158,15 @@ var XUI_Root = XUI_Box.inherits(
                },
                
                start : function(){
-
-                       
                        this.initialize( this.User, this, null, null );
                        X_Timer_once( 0, this, this.addToView );
                },
                addToView : function(){
                        // XUI_xnodeInteractionOverlay の前に追加する!
                        this.addToParent( X_Node_body );
-                       
+
                        XUI_xnodeInteractionOverlay = X_Node_body.create( 'div', {
-                               'class'      : 'mouse-operation-catcher',
+                               'class'      : XUI_mousemoveFix ? 'mouse-operation-catcher-scrollFix' : 'mouse-operation-catcher',
                                unselectable : 'on'
                        } );
                        
@@ -133,7 +175,12 @@ var XUI_Root = XUI_Box.inherits(
                        // hover や rollover rollout のための move イベントの追加
                        // TODO この切り替えを ViewPort へ
                        XUI_xnodeIneraction = ( X_UA[ 'IE' ] < 9 ? X_ViewPort_document : X_UA[ 'Opera' ] < 8 ? X_Node_body : X_ViewPort );
-                       XUI_xnodeIneraction[ 'listen' ]( 'pointermove', X_UI_eventRellay );
+                       
+                       if( XUI_mousemoveFix ){
+                               XUI_xnodeInteractionOverlay[ 'listen' ]( [ 'scroll', 'mouseup' ], X_UI_eventRellay )[ 'create' ]( 'div' );
+                       } else {
+                               XUI_xnodeIneraction[ 'listen' ]( 'pointermove', X_UI_eventRellay );
+                       };
                        
                        if( XUI_EVENT_COUNTER[ XUI_Event._POINTER_MOVE ] ){
                                ++XUI_EVENT_COUNTER[ XUI_Event._POINTER_MOVE ];
@@ -151,7 +198,7 @@ var XUI_Root = XUI_Box.inherits(
                },
                
                reserveCalc : function(){
-                       if( this.calcReserved === false ){
+                       if( !this.calcReserved ){
                                this.calcReserved = true;
                                X_Timer_once( 0, this, this.calculate );
                        };
@@ -164,6 +211,8 @@ var XUI_Root = XUI_Box.inherits(
                                return X_CALLBACK_NONE;
                        };
                        
+                       XUI_mousemoveFix && XUI_mousemoveFixResetScroll();
+                       
                        size = X[ 'ViewPort' ][ 'getSize' ]();
                        font = X[ 'ViewPort' ][ 'getBaseFontSize' ]();
                        this.layout.calculate( this, false, 0, 0, size[ 0 ] / font, size[ 1 ] / font );