Changeset 3

Show
Ignore:
Timestamp:
05/30/08 03:19:06 (4 years ago)
Author:
tsuckowhomberg
Message:
  • fixed: wrong calculation in BufferedGridView?.onLiveScroll (based on lastScrollPosition and actual scrollPosition) caused the view sometimes to not re-render some rows
  • fixed: provided bug fix for "ensureVisible: returned x-coordinate does not take the x-position of the gridpanel into account" (see  http://extjs.com/forum/showthread.php?p=175331#post175331)
  • enhancement: added cfg option "scrollDelay" in BufferedGridView? for buffering calls to onLiveScroll when scroll-event gets fired (thanks to Rich Waters)
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG

    r2 r3  
    1 2008-05-28 
     12008-05-29 
     2========== 
     3- fixed: wrong calculation in BufferedGridView.onLiveScroll (based on lastScrollPosition and actual  
     4scrollPosition) caused the view sometimes to not re-render some rows 
     5- fixed: provided bug fix for "ensureVisible: returned x-coordinate does not take the x-position 
     6of the gridpanel into account" (see http://extjs.com/forum/showthread.php?p=175331#post175331) 
     7- enhancement: added cfg option "scrollDelay" in BufferedGridView for buffering calls to onLiveScroll  
     8when scroll-event gets fired (thanks to Rich Waters) 
     9 
     10 
     112008-05-28 
    212========== 
    313- fixed: wrong calculation of last displayable row after removing a row caused selection-model 
  • trunk/src/BufferedGridView.js

    r2 r3  
    2020Ext.ux.grid.BufferedGridView = function(config) { 
    2121     
    22         this.addEvents({ 
    23             /** 
    24              * @event beforebuffer 
    25              * Fires when the store is about to buffer new data. 
    26              * @param {Ext.ux.BufferedGridView} this 
    27              * @param {Ext.data.Store} store The store 
    28              * @param {Number} rowIndex 
    29              * @param {Number} visibleRows 
    30              * @param {Number} totalCount 
    31              */ 
    32             'beforebuffer' : true, 
    33             /** 
    34              * @event buffer 
    35              * Fires when the store is finsihed buffering new data. 
    36              * @param {Ext.ux.BufferedGridView} this 
    37              * @param {Ext.data.Store} store The store 
    38              * @param {Number} rowIndex 
    39              * @param {Number} visibleRows 
    40              * @param {Number} totalCount 
    41              */ 
    42             'buffer' : true, 
    43             /** 
    44              * @event cursormove 
    45              * Fires when the the user scrolls through the data. 
    46              * @param {Ext.ux.BufferedGridView} this 
    47              * @param {Number} rowIndex The index of the first visible row in the 
    48              *                          grid absolute to it's position in the model. 
    49              * @param {Number} visibleRows The number of rows visible in the grid. 
    50              * @param {Number} totalCount              
    51              */ 
    52             'cursormove' : true 
    53              
    54         });    
     22    this.addEvents({ 
     23        /** 
     24         * @event beforebuffer 
     25         * Fires when the store is about to buffer new data. 
     26         * @param {Ext.ux.BufferedGridView} this 
     27         * @param {Ext.data.Store} store The store 
     28         * @param {Number} rowIndex 
     29         * @param {Number} visibleRows 
     30         * @param {Number} totalCount 
     31         */ 
     32        'beforebuffer' : true, 
     33        /** 
     34         * @event buffer 
     35         * Fires when the store is finsihed buffering new data. 
     36         * @param {Ext.ux.BufferedGridView} this 
     37         * @param {Ext.data.Store} store The store 
     38         * @param {Number} rowIndex 
     39         * @param {Number} visibleRows 
     40         * @param {Number} totalCount 
     41         */ 
     42        'buffer' : true, 
     43        /** 
     44         * @event cursormove 
     45         * Fires when the the user scrolls through the data. 
     46         * @param {Ext.ux.BufferedGridView} this 
     47         * @param {Number} rowIndex The index of the first visible row in the 
     48         *                          grid absolute to it's position in the model. 
     49         * @param {Number} visibleRows The number of rows visible in the grid. 
     50         * @param {Number} totalCount              
     51         */ 
     52        'cursormove' : true 
     53         
     54    });    
     55     
     56    /** 
     57     * @cfg {Number} scrollDelay The number of microseconds a call to the  
     58     * onLiveScroll-lisener should be delayed when the scroll event fires 
     59     */ 
    5560     
    5661    /** 
     
    347352        this.liveScroller       = new E(cs[0]); 
    348353        this.liveScrollerInset  = this.liveScroller.dom.firstChild; 
    349         this.liveScroller.on('scroll', this.onLiveScroll,  this); 
     354        this.liveScroller.on('scroll', this.onLiveScroll,  this, {buffer : this.scrollDelay}); 
    350355         
    351356            this.mainHd = new E(this.mainWrap.dom.firstChild); 
     
    934939    { 
    935940        var scrollTop     = this.liveScroller.dom.scrollTop;  
    936         var pixelsSkipped = scrollTop-this.lastScrollPos; 
    937          
    938         var rowsSkipped = Math.floor(pixelsSkipped/this.rowHeight); 
    939          
    940         // happens when no scrolling actually happened 
    941         if (pixelsSkipped == 0) { 
    942             return; 
    943         } 
    944941         
    945942        var cursor = Math.floor((scrollTop)/this.rowHeight); 
    946943        this.rowIndex = cursor; 
    947         // the lastRowIndex will be set when refreshing the view finished 
     944        // the lastRowIndex will be set when refreshing the view has finished 
    948945        if (cursor == this.lastRowIndex) { 
    949946            return; 
    950947        } 
    951948         
    952         this.updateLiveRows(cursor, rowsSkipped); 
    953          
     949        this.updateLiveRows(cursor); 
    954950        this.lastScrollPos = this.liveScroller.dom.scrollTop;  
    955951    },     
     
    10931089        if (!xy) { 
    10941090                return; 
    1095                                 } 
    1096         this.focusEl.setXY(xy); 
     1091                } 
     1092                this.focusEl.setXY(xy); 
     1093         
    10971094        if(Ext.isGecko){ 
    10981095            this.focusEl.focus(); 
     
    11151112            row = row.rowIndex; 
    11161113        } 
     1114         
    11171115        if(row < 0 || row >= this.ds.totalLength){ 
    11181116            return; 
     
    11241122        if (row >= this.rowIndex+this.visibleRows) { 
    11251123            this.adjustScrollerPos(((row-(this.rowIndex+this.visibleRows))+1)*this.rowHeight); 
    1126         } else if (row < this.rowIndex) { 
     1124        } else if (row <= this.rowIndex) { 
    11271125            this.adjustScrollerPos((rowInd)*this.rowHeight); 
    11281126        }  
    11291127        var rowInd = rowInd < 0 ? row : rowInd; 
    11301128        var rowEl = this.getRow(rowInd), cellEl; 
     1129         
    11311130        if(!(hscroll === false && col === 0)){ 
    11321131            while(this.cm.isHidden(col)){ 
     
    11401139         
    11411140        var c = this.scroller.dom; 
    1142  
    1143                 return cellEl ? Ext.fly(cellEl).getXY() : [c.scrollLeft, Ext.fly(rowEl).getY()]; 
     1141         
     1142        return cellEl ?  
     1143            Ext.fly(cellEl).getXY() :  
     1144            [c.scrollLeft+this.el.getX(), Ext.fly(rowEl).getY()]; 
    11441145    },    
    11451146 
     
    15041505            liveScroller.un('scroll', this.onLiveScroll, this); 
    15051506        } 
    1506         this.lastScrollPos    = scrollDom.scrollTop;  
     1507        this.lastScrollPos   = scrollDom.scrollTop;  
    15071508        scrollDom.scrollTop += pixels; 
    15081509         
    15091510        if (suspendEvent === true) { 
    15101511            scrollDom.scrollTop = scrollDom.scrollTop; 
    1511             liveScroller.on('scroll', this.onLiveScroll, this); 
     1512            liveScroller.on('scroll', this.onLiveScroll, this, {buffer : this.scrollDelay}); 
    15121513        } 
    15131514