OSDN Git Service

Version 0.6.182, fix X.UA.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 15_ScrollBox.js
index 47915ff..817ebdb 100644 (file)
@@ -1,4 +1,8 @@
-\r
+/*\r
+ * scroll 要素は常にひとつ\r
+ * ScrollManager\r
+ * indicatorX, Y は再利用\r
+ */\r
 \r
 \r
 var X_UI_ScrollBox_SUPPORT_ATTRS = {\r
@@ -40,7 +44,6 @@ var XUI_ScrollBox = XUI_ChromeBox.inherits(
                directionLocked : '',\r
                startTime       : 0,\r
                endTime         : 0,\r
-               isAnimating     : false,\r
                isInTransition  : false,\r
 \r
                hasHScroll      : false,\r
@@ -77,6 +80,9 @@ var XUI_ScrollBox = XUI_ChromeBox.inherits(
                _containerNode   : null,\r
                xnodeSlider      : null,\r
                \r
+               xnodeIndicatorX  : null,\r
+               xnodeIndicatorY  : null,\r
+               \r
                Constructor : function( user, layout, args ){\r
                        this[ 'Super' ]( user, layout, args );\r
                        this._containerNode = X_Pair_get( this.containerNode );\r
@@ -133,18 +139,18 @@ var XUI_ScrollBox = XUI_ChromeBox.inherits(
 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
+               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.xnodeSlider[ 'stop' ]();\r
        this.isInTransition = false;\r
-       return X_Callback_NONE;\r
+       return X_CALLBACK_NONE;\r
 };\r
 \r
 function X_UI_ScrollBox_onLayoutComplete( e ){\r
        // scroll の停止、GPU の解除\r
-       var font = this.fontSize = this.xnodeSlider.call( 'fontSize' );\r
+       var font = this.fontSize = this.xnodeSlider[ 'call' ]( 'fontSize' );\r
 \r
        this.scrollXMax = ( this.boxWidth  - this._containerNode.boxWidth )  * font | 0;\r
        this.scrollYMax = ( this.boxHeight - this._containerNode.boxHeight ) * font | 0;\r
@@ -183,7 +189,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
        if( this.scrolling ){\r
                // scroller 削除\r
                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
+               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, 100, '', 300 );\r
                \r
@@ -200,7 +206,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
                        opt_easing  = opt_easing === '' ? '' : opt_easing || 'circular';\r
                        opt_release = 0 <= opt_release ? opt_release : 300;\r
                        \r
-                       that.xnodeSlider.animate(\r
+                       that.xnodeSlider[ 'animate' ](\r
                                {\r
                                        x : that.scrollX,\r
                                        y : that.scrollY\r
@@ -223,7 +229,7 @@ function X_UI_ScrollBox_onLayoutComplete( e ){
                };\r
 \r
 function X_UI_ScrollBox_onStart( e ){\r
-       var ret = X_Callback_NONE;\r
+       var ret = X_CALLBACK_NONE;\r
 \r
        // React to left mouse button only\r
        if( e.pointerType === 'mouse' && e.button !== 0 ){\r
@@ -244,10 +250,11 @@ function X_UI_ScrollBox_onStart( e ){
        this.startTime       = X_Timer_now();\r
 \r
        // スクロール中の停止\r
-       if( this.isInTransition || this.isAnimating ){\r
-               this.isInTransition = this.isAnimating = false;\r
+       if( this.isInTransition ){\r
+               this.isInTransition = false;\r
                this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
-               this.xnodeSlider.stop();\r
+               // TODO current位置\r
+               this.xnodeSlider[ 'stop' ]();\r
        };                      \r
 \r
        this.startX    = this.scrollX;\r
@@ -262,17 +269,17 @@ function X_UI_ScrollBox_onStart( e ){
        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
-       return ret | X_Callback_PREVENT_DEFAULT;\r
+       return ret | X_CALLBACK_PREVENT_DEFAULT;\r
 };\r
 \r
 function X_UI_ScrollBox_onMove( e ){\r
-       var ret = X_Callback_NONE,\r
+       var ret = X_CALLBACK_NONE,\r
                deltaX, deltaY, timestamp,\r
                newX, newY,\r
                absDistX, absDistY;\r
        // 規定以上の move でスクロール開始\r
 \r
-console.log( 'scrollmove ' + e.buttons + ' ' + e.button );\r
+//console.log( 'scrollmove ' + e.buttons + ' ' + e.button );\r
 \r
        if( !this.scrollEnabled || e.pointerType !== this.initiated ){\r
                return ret;\r
@@ -363,11 +370,11 @@ console.log( 'scrollmove ' + e.buttons + ' ' + e.button );
                this.startY = this.scrollY;\r
        };\r
        // イベントの拘束\r
-       return ret | X_Callback_PREVENT_DEFAULT | X_Callback_CAPTURE_POINTER;\r
+       return ret | X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_CAPTURE_POINTER;\r
 };\r
 \r
 function X_UI_ScrollBox_onEnd( e ){\r
-       var ret    = X_Callback_NONE,\r
+       var ret    = X_CALLBACK_NONE,\r
                time   = 0,\r
                easing = '',\r
                newX, newY,\r
@@ -463,8 +470,8 @@ function X_UI_ScrollBox_resetPosition( that, time ){
                return false;\r
        };\r
 \r
-       //console.log( 'バウンド!' );\r
-       //console.log( 'rese x:' + x + ' y:' + y );\r
+       console.log( ' ===> resetPosition - バウンド!' );\r
+       console.log( '      x:' + x + ' y:' + y );\r
        that.scrollTo( x, y, time, that.bounceEasing, 1000 );\r
 \r
        return true;\r
@@ -472,13 +479,13 @@ function X_UI_ScrollBox_resetPosition( that, time ){
 \r
 function X_UI_ScrollBox_onAnimeEnd( e ){\r
        if( e.target !== this.xnodeSlider || !this.isInTransition ){\r
-               return X_Callback_NONE;\r
+               return X_CALLBACK_NONE;\r
        };\r
        if( !X_UI_ScrollBox_resetPosition( this, this.bounceTime ) ){\r
                this.isInTransition = false;\r
                this[ 'dispatch' ]( XUI_Event.SCROLL_END );\r
        };\r
-       return X_Callback_NONE;\r
+       return X_CALLBACK_NONE;\r
 };\r
 \r
 function X_UI_ScrollBox_momentum( current, start, time, lowerMargin, wrapperSize, deceleration ){\r
@@ -509,7 +516,6 @@ function X_UI_ScrollBox_momentum( current, start, time, lowerMargin, wrapperSize
        };\r
 };\r
 \r
-// TODO Box の継承に!\r
 X.UI.ScrollBox = X.UI.ChromeBox.inherits(\r
        'ScrollBox',\r
        X_Class.NONE,\r
@@ -520,7 +526,7 @@ X.UI.ScrollBox = X.UI.ChromeBox.inherits(
                        if( XUI_ScrollBox.prototype.usableAttrs === XUI_ChromeBox.prototype.usableAttrs ){\r
                                XUI_ScrollBox.prototype.usableAttrs = supports = XUI_Attr_createAttrDef( XUI_Attr_Support, X_UI_ScrollBox_SUPPORT_ATTRS );\r
                \r
-                               XUI_ScrollBox.prototype.attrClass    = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { width  : '100%', height : '100%', bgColor : 0x111111 } );\r
+                               XUI_ScrollBox.prototype.attrClass   = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { width  : '100%', height : '100%', bgColor : 0x111111 } );\r
                        };\r
                        \r
                        var args = [\r
@@ -580,4 +586,5 @@ X.UI.ScrollBox = X.UI.ChromeBox.inherits(
                        \r
                }\r
        }\r
-);
\ No newline at end of file
+);\r
+\r