OSDN Git Service

Version 0.6.143, fix X.UI.ScrollBox for iOS3.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 15_ScrollBox.js
index 15a613f..be6884f 100644 (file)
@@ -42,7 +42,6 @@ var X_UI_ScrollBox_SUPPORT_ATTRS = {
                scrollShadowColor      : [ '#000', XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.COLOR ]\r
        };\r
 \r
-\r
 var XUI_ScrollBox = XUI_ChromeBox.inherits(\r
        '_ScrollBox',\r
        X_Class.PRIVATE_DATA,\r
@@ -159,9 +158,15 @@ var XUI_ScrollBox = XUI_ChromeBox.inherits(
 );\r
 \r
 function X_UI_ScrollBox_onLayoutBefore( e ){\r
+       if( e[ 'cancelable' ] && this.isInTransition && X_Node_Anime_translateZ ){\r
+               this[ 'listenOnce' ]( XUI_Event.SCROLL_END, X_UI_rootData, X_UI_rootData.calculate );\r
+               return X_Callback_PREVENT_DEFAULT;\r
+       };\r
        this.scrollXRatio = this.scrollX ? this.scrollXMax / this.scrollX : 0;\r
        this.scrollYRatio = this.scrollY ? this.scrollYMax / this.scrollY : 0;\r
        this.xnodeSlider.stop();\r
+       this.isInTransition = false;\r
+       return X_Callback_NONE;\r
 };\r
 \r
 function X_UI_ScrollBox_onLayoutComplete( e ){\r
@@ -176,34 +181,28 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
 \r
        if( !this.hasHScroll ){\r
                this.scrollXMax  = 0;\r
-               //this.scrollWidth = this.boxWidth;\r
        };\r
 \r
        if( !this.hasVScroll ){\r
                this.scrollYMax   = 0;\r
-               //this.scrollHeight = this.boxHeight;\r
        };\r
 \r
        delete this.endTime;\r
        delete this.directionX;\r
        delete this.directionY;\r
 \r
-       //this.wrapperOffset = this.xnodeWrapper[ 'offset' ]();\r
-\r
-       //this[ 'dispatch' ]('refresh');\r
-\r
        X_UI_ScrollBox_resetPosition( this, 0 );\r
 \r
        if( this.hasHScroll || this.hasVScroll ){\r
                // scroll が必要。\r
                if( this.scrolling ){\r
-                       X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 0, '', 0 );\r
+                       X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
                } else {\r
                        // scroller 作る\r
                        this[ 'listen' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
                        X_UI_rootData[ 'listen' ]( XUI_Event.LAYOUT_BEFORE, this, X_UI_ScrollBox_onLayoutBefore );\r
                        \r
-                       X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 0, '', 0 );\r
+                       X_UI_ScrollBox_translate( this, this.scrollXMax * this.scrollXRatio, this.scrollYMax * this.scrollYRatio, 100, '', 300 );\r
                        this.scrolling = true;\r
                };\r
        } else\r
@@ -213,7 +212,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
                this[ 'unlisten' ]( XUI_Event._POINTER_DOWN, this, X_UI_ScrollBox_onStart );\r
                X_UI_rootData[ 'unlisten' ]( XUI_Event.LAYOUT_BEFORE,   this, X_UI_ScrollBox_onLayoutBefore );\r
                \r
-               ( this.scrollX !== 0 || this.scrollY !== 0 ) && X_UI_ScrollBox_translate( this, 0, 0, 0, '', 0 );\r
+               ( this.scrollX !== 0 || this.scrollY !== 0 ) && X_UI_ScrollBox_translate( this, 0, 0, 100, '', 300 );\r
                \r
                delete this.scrolling;\r
                delete this.scrollXRatio;\r
@@ -221,6 +220,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
        };\r
 };\r
 \r
+               // TODO use scrollLeft, scrollTop\r
                function X_UI_ScrollBox_translate( that, x, y, opt_time, opt_easing, opt_release ){\r
                        \r
                        opt_time    = 0 <= opt_time ? opt_time : 0;\r
@@ -274,6 +274,7 @@ function X_UI_ScrollBox_onStart( e ){
        if( this.isInTransition || this.isAnimating ){\r
                this.isInTransition = this.isAnimating = false;\r
                this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
+               this.xnodeSlider.stop();\r
        };                      \r
 \r
        this.startX    = this.scrollX;\r
@@ -283,6 +284,8 @@ function X_UI_ScrollBox_onStart( e ){
        this.pointX    = e.pageX;\r
        this.pointY    = e.pageY;\r
        \r
+       console.log( 'scrollstart ' + e.pageY );\r
+       \r
        this[ 'listen' ]( XUI_Event._POINTER_MOVE, this, X_UI_ScrollBox_onMove );\r
        this[ 'listen' ]( [ XUI_Event._POINTER_UP, XUI_Event._POINTER_CANCEL ], this, X_UI_ScrollBox_onEnd );\r
 \r
@@ -295,7 +298,9 @@ function X_UI_ScrollBox_onMove( e ){
                newX, newY,\r
                absDistX, absDistY;\r
        // 規定以上の move でスクロール開始\r
-       \r
+\r
+console.log( 'scrollmove ' + e.buttons + ' ' + e.button );\r
+\r
        if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
                return ret;\r
        };\r
@@ -421,7 +426,7 @@ function X_UI_ScrollBox_onEnd( e ){
        // we scrolled less than 10 pixels\r
        if( !this.moved ){\r
                // this[ 'dispatch' ]( X_EVENT_CANCELED );\r
-               console.log( 'we scrolled less than 10 pixels' );\r
+               console.log( 'we scrolled less than 10 pixels ' + e.pageY );\r
                return ret;\r
        };\r
 \r