OSDN Git Service

fixed scroll of Finder.
authoritozyun <itozyun@gmail.com>
Tue, 18 Dec 2012 21:35:14 +0000 (06:35 +0900)
committeritozyun <itozyun@gmail.com>
Tue, 18 Dec 2012 21:35:14 +0000 (06:35 +0900)
0.5.x/javascripts/peta.apps.js
0.5.x/javascripts/system.js
0.5.x/stylesheets/system.css

index 509f337..d21ca21 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR peta.apps.js
- *   version 0.5.33
+ *   version 0.5.34
  *   
  * author:
  *   itozyun
@@ -563,8 +563,8 @@ var Gallery = gOS.registerApplication( function(){
                
                tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT );
                var     _root  = tree.getRootFile(),
-                       _myPic = _root.getChildFileByIndex( 0 ),
-                       _pic   = _root.getChildFileByIndex( 1 );
+                       _myPic = _root.getChildFileAt( 0 ),
+                       _pic   = _root.getChildFileAt( 1 );
                _myPic.getSeqentialFiles();
                _pic.getSeqentialFiles();
                _myPic.destroy();
@@ -788,11 +788,11 @@ var PremiumSatge = gOS.registerApplication( function(){
                                id:   artistID,
                                type: FILE_TYPE.ARTIST
                        })[ 0 ],
-                       _artistFile = rootFile.getChildFileByIndex( _index ),
+                       _artistFile = rootFile.getChildFileAt( _index ),
                        _file;
                if( _artistFile !== null ){
                        for(var i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
-                               _file = _artistFile.getChildFileByIndex( i );
+                               _file = _artistFile.getChildFileAt( i );
                                ICON_ARRAY.push( new ImageGroupIconClass( i, FileAPI.getFileData( _file ) ));
                                _file.destroy();
                        }
@@ -2156,8 +2156,8 @@ var Editor = gOS.registerApplication( function(){
                                onFirstOpen: function( _w, _h, nodeBody ){
                                        tree = FileAPI.createTree( FILE_DATA_PICTURE_ROOT );
                                        var     _root  = tree.getRootFile(),
-                                               _myPic = _root.getChildFileByIndex( 0 ),
-                                               _pic   = _root.getChildFileByIndex( 1 );
+                                               _myPic = _root.getChildFileAt( 0 ),
+                                               _pic   = _root.getChildFileAt( 1 );
                                        _myPic.getSeqentialFiles();
                                        _pic.getSeqentialFiles();
                                        _myPic.destroy();
index 94a908b..b2afa97 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR system.js
- *   version 0.5.32
+ *   version 0.5.34
  *
  * gadgetOS
  *   author:
@@ -645,7 +645,7 @@ var File = ( function(){
                this.down = function( _index ){
                        if( typeof _index !== 'number' || _index < 0 || _index >= currentFile.getChildFileLength()) return;
                        PARENT_FILE_RESITER.unshift( currentFile );
-                       currentFile = currentFile.getChildFileByIndex( _index );
+                       currentFile = currentFile.getChildFileAt( _index );
                        currentFile.getSeqentialFiles();
                        return currentFile;
                };
@@ -729,7 +729,7 @@ var File = ( function(){
 
                this.getUID = function(){
                        return uid;
-               }
+               };
        };
        
        FileClass.prototype = {
@@ -766,10 +766,10 @@ var File = ( function(){
                        }
                        return -1;
                },
-               getChildFileByIndex: function( _index ){
+               getChildFileAt: function( _index ){
                        var _access = FILE_CONTROLER.getFileDataAccess( this ),
                                _children = FILE_CONTROLER.getChildren( this );
-                       if( typeof _index !== 'number' || _index < 0 || Type.isArray( _children ) === false || _index >= _children.length) return null;
+                       if( typeof _index !== 'number' || _index < 0 || Type.isArray( _children ) === false || _index >= _children.length ) return null;
                        var _file = new FileClass( _access.TREE, _access.DATA, _children[ _index ]);
                        // _file.init();
                        return _file;
@@ -1349,8 +1349,7 @@ var PointingDeviceEventTree = ( function(){
                currentRootData = null,
                targetNodeData  = null,
                forceNodeData   = null,
-               hoverList       = [],
-               c               = 0;
+               hoverList       = [];
        
        function eventRellay( e ){
                var data = forceNodeData, // || targetNodeData,
@@ -1887,14 +1886,14 @@ var PointingDeviceEventTree = ( function(){
                                this._scrillX = v;
                                ScrollBarManager.update( this );
                        };
-                       return this._scrollX;
+                       return this.scrollingX; // this._scrollX;
                },
                scrollY : function( v ){
                        if( Type.isFinite( v ) === true ){
                                this._scrillY = v;
                                ScrollBarManager.update( this );
                        };
-                       return this._scrollY;
+                       return this.scrollingY; // this._scrollY;
                },
                nodeIndex : function( v ){
                        var list, i;
@@ -2061,7 +2060,8 @@ var PointingDeviceEventTree = ( function(){
                var elmScroller     = document.createElement( 'div' ),
                        elmBar          = document.createElement( 'div' ),
                        smoothList      = [],
-                       currentNodeData = null;
+                       currentNodeData = null,
+                       currentEvent;
                
                function tick(){
                        var list = smoothList,
@@ -2077,9 +2077,11 @@ var PointingDeviceEventTree = ( function(){
                                        };
                                        data.scrollingY    = y;
                                        data.elm.scrollTop = -y;
+                                       data.events && data.events.scroll && data.fire( currentEvent, 'scroll', true );
                                };
                                if( data.scrollingY === data._scrollY ){
                                        list.splice( i, 1 );
+                                       // data.events && data.events.scroll && data.fire( currentEvent, 'scroll', true );
                                } else {
                                        ++i;
                                };
@@ -2125,6 +2127,7 @@ var PointingDeviceEventTree = ( function(){
                        var data = this;
                        this._scrollY += e.wheelDelta;
                        ScrollBarManager.update( this );
+                       currentEvent = e;
                        return true;
                };
                function onMouseDragScroll( e ){
@@ -2133,6 +2136,7 @@ var PointingDeviceEventTree = ( function(){
                        this._scrollY = this.scrollStartY + e.dragOffsetY;
                        ScrollBarManager.update( this );
                        this.scrollStartY = this._scrollY;
+                       currentEvent = e;
                        return true;
                };
                
@@ -5202,6 +5206,7 @@ var Finder = ( function(){
                                this.elmRoot  = elm;
                        };
                        this.nodeRoot.addEventListener( 'click', this.onIconClick, this );
+                       this.nodeRoot.addEventListener( 'scroll', this.onScroll, this );
                        
                        this.elmScroll    = document.createElement( 'div' );
                        this.elmRoot.appendChild( this.elmScroll );
@@ -5225,17 +5230,62 @@ var Finder = ( function(){
                },
                onIconClick : function( e ){
                        var target = e.target,
-                               i      = target.nodeIndex(),
+                               list   = this.iconList,
+                               i, icon,
                                file;
                        if( target === this.nodeRoot ) return;
-                       var file = this.tree.getCurrentFile().getChildFileByIndex( i );
-                       if( file !== null && ( file.getChildFileLength() !== -1 || file.getType() === Const.FILE.TYPE.FOLDER )){
-                               this.tree.down( i );
-                               this.draw();
-                       } else {
-                               Type.isFunction( this.onSelect ) === true && this.onSelect( file );
+                       for( i = list.length; i; ){
+                               icon = list[ --i ];
+                               if( icon.node === target ){
+                                       i = icon._index;
+                                       file = this.tree.getCurrentFile().getChildFileAt( i );
+                                       if( file !== null && ( file.getChildFileLength() !== -1 || file.getType() === Const.FILE.TYPE.FOLDER )){
+                                               this.tree.down( i );
+                                               this.draw();
+                                       } else {
+                                               Type.isFunction( this.onSelect ) === true && this.onSelect( file );
+                                       };
+                                       file.destroy();
+                                       break;
+                               };
+                       };
+               },
+               onScroll : function( e ){
+                       var _w       = this.w;
+                       
+                       var data     = this,
+                               iconList = data.iconList,
+                               folder   = data.tree.getCurrentFile(),
+                               i        = 0,
+                               j        = 0,
+                               l        = folder.getChildFileLength(),
+                               scrollY  = -this.nodeRoot.scrollY(),
+                               rootH    = scrollY + this.nodeRoot.height(),
+                               startIndex = 0 < iconList.length ? iconList[ 0 ]._index : 0,
+                               icon;
+                       
+                       console.log( ' > ' + scrollY + ' , ' + rootH )
+                       for( ; i < l; ++i ){
+                               if( ( i + 1 ) * ICON_HEIGHT < scrollY || rootH < i * ICON_HEIGHT ){
+                                       if( iconList.length <= j ) continue;
+                                       icon = iconList[ j ];
+                                       if( icon._index !== i ) continue;
+                                       icon.destroy();
+                                       iconList.splice( j, 1 );
+                                       continue;
+                               };
+                               if( iconList.length <= j || iconList[ j ]._index !== i ){
+                                       if( i < startIndex ){
+                                               iconList.splice( j, 0, FinderIconClass.get( this, folder.getChildFileAt( i ), _w, i, data.style ) );                    
+                                       } else
+                                       if( startIndex + iconList.length <= i ){
+                                               iconList.push( FinderIconClass.get( this, folder.getChildFileAt( i ), _w, i, data.style ) );                    
+                                       };                                      
+                               };
+                               ++j;
                        };
-                       file.destroy();
+                       
+                       //while( j < iconList.length ) iconList.pop().destroy();
                },
                onPathClick : function( e ){
                        var target = e.target,
@@ -5250,13 +5300,13 @@ var Finder = ( function(){
                        data.h   = _h = Type.isFinite( _h ) === true ? _h : data.h;
                        data.elmPath && data.drawPath( _w );
                        data.drawBody( _w, _h );
+                       data.nodeRoot.invalidateScrollbar();
                },
                drawPath : function( _w ){
                        if( !this.elmPath.parentNode ) return;
                        
                        var data      = this,
                                tree      = data.tree,
-                               apiuser   = data.apiuser,
                                pathList  = data.pathList,
                                i         = 0,
                                l         = tree.hierarchy() + 1,
@@ -5275,26 +5325,30 @@ var Finder = ( function(){
                },
                drawBody : function( _w, _h ){
                        var data     = this,
-                               apiuser  = data.apiuser,
                                iconList = data.iconList,
                                file     = data.tree.getCurrentFile(),
                                i        = 0,
+                               j        = 0,
                                l        = file.getChildFileLength(),
-                               m        = iconList.length;
+                               m        = iconList.length,
+                               scrollY  = -this.nodeRoot.scrollY(),
+                               rootH    = scrollY + this.nodeRoot.height(),
+                               icon;
 
                        for( ; i < l; ++i ){
-                               if( i < m ){
-                                       iconList[ i ].init( this, file.getChildFileByIndex( i ), _w, i, data.style );
+                               if( ( i + 1 ) * ICON_HEIGHT < scrollY || rootH < i * ICON_HEIGHT ) continue;
+                               if( j < m ){
+                                       iconList[ j ].init( this, file.getChildFileAt( i ), _w, i, data.style );
                                } else {
-                                       iconList.push( FinderIconClass.get( this, file.getChildFileByIndex( i ), _w, i, data.style ) );
+                                       iconList.push( FinderIconClass.get( this, file.getChildFileAt( i ), _w, i, data.style ) );
                                };
+                               j++;
                        };
                        data.elmRoot.className    = file.getState() === Const.FILE.STATE.LOADING ? 'finder-body loading' : 'finder-body';
                        // data.elmRoot.style.height = ( data.h - data.headH ) + 'px';
                        
-                       while( l < iconList.length ) iconList.pop().destroy();
-                       
-                       this.nodeRoot.invalidateScrollbar();
+                       while( j < iconList.length ) iconList.pop().destroy();
+                       data.elmScroll.style.height = ( l * ICON_HEIGHT ) + 'px';
                },
                createPath : function( node ){
                        if( this.elmPath ) return;
@@ -5354,14 +5408,14 @@ var Finder = ( function(){
                MIN_WIDTH  : 200,
                MIN_HEIGHT : 200,
                init       : function(){
-               var data = FinderPrivateData.get( this );
+                       var data = FinderPrivateData.get( this );
                        // var position = Util.getAbsolutePosition( elmPath );
                        // data.headX = position.x;
                        // data.headY = position.y;
                        // data.bodyY = Util.getAbsolutePosition( data.elmBody ).y;
-                       data.apiuser.addEventListener( data.elmRoot, 'mousemove',  data.mousemove,  data );
-                       data.apiuser.addEventListener( data.elmRoot, 'click',      data.click,      data );
-                       data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data );
+                       //data.apiuser.addEventListener( data.elmRoot, 'mousemove',  data.mousemove,  data );
+                       //data.apiuser.addEventListener( data.elmRoot, 'click',      data.click,      data );
+                       //data.apiuser.addEventListener( data.elmRoot, 'mousewheel', data.mousewheel, data );
                },
                resize : function( w, h ){
                        var data = FinderPrivateData.get( this ),
index 03f0adb..973fb7f 100644 (file)
@@ -1,7 +1,7 @@
 @charset "UTF-8";\r
 \r
 /* pettanR system.css\r
- *   version 0.5.33\r
+ *   version 0.5.34\r
  * \r
  *   author:\r
  *     itozyun\r
                background-color:               #484848;\r
        }\r
                .finder-path div {\r
-                       list-style:                             none;\r
                        position:                               absolute;\r
                        top:                                    0;\r
-                       left:                                   48px;\r
+                       left:                                   0;\r
+                       overflow:                               hidden;\r
+                       width:                                  90px;\r
                        height:                                 40px;\r
+                       font-size:                              14px;\r
                        line-height:                    40px;\r
-                       padding:                                0;\r
+                       padding:                                0 0 0 15px;\r
                        margin:                                 0;\r
+                       color:                                  #eee;\r
+                       background-image       : url( ../images/finder_path_shadow.gif );\r
+                       background-position    : 0 40px;\r
+                       background-repeat      : repeat-y;\r
+               }\r
+               .finder-path-hover {\r
+                       background-color:               #66f !important;\r
+                       background-position    : 0 0 !important;\r
+                       color                  : #fff;\r
                }\r
-                       .finder-path div {\r
-                               position:                               absolute;\r
-                               top:                                    0;\r
-                               left:                                   0;\r
-                               height:                                 40px;\r
-                               width:                                  90px;\r
-                               padding:                                0;\r
-                               margin:                                 0;\r
-                               font-size:                              14px;\r
-                               line-height:                    40px;\r
-                               margin:                                 0;\r
-                               color:                                  #eee;\r
-                               overflow:                               hidden;\r
-                       }\r
-                       .finder-path-hover {\r
-                               text-decoration:                none;\r
-                               background-color:               #66f;\r
-                               color:                                  #eee;\r
-                       }\r
                \r
        /*  Finder Icon\r
        --------------------------------------------------------------------------------------*/\r
        .finder-icon {\r
-               /* position:                                    absolute; */\r
+               position:                                       absolute;\r
                left:                                           0;\r
                height:                                         74px;\r
                border-bottom:                          1px solid #ccc;\r