/*
* pettanR system.js
- * version 0.5.32
+ * version 0.5.34
*
* gadgetOS
* author:
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;
};
this.getUID = function(){
return uid;
- }
+ };
};
FileClass.prototype = {
}
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;
currentRootData = null,
targetNodeData = null,
forceNodeData = null,
- hoverList = [],
- c = 0;
+ hoverList = [];
function eventRellay( e ){
var data = forceNodeData, // || targetNodeData,
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;
var elmScroller = document.createElement( 'div' ),
elmBar = document.createElement( 'div' ),
smoothList = [],
- currentNodeData = null;
+ currentNodeData = null,
+ currentEvent;
function tick(){
var list = smoothList,
};
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;
};
var data = this;
this._scrollY += e.wheelDelta;
ScrollBarManager.update( this );
+ currentEvent = e;
return true;
};
function onMouseDragScroll( e ){
this._scrollY = this.scrollStartY + e.dragOffsetY;
ScrollBarManager.update( this );
this.scrollStartY = this._scrollY;
+ currentEvent = e;
return true;
};
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 );
},
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,
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,
},
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;
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 ),