Skip to content

Commit

Permalink
- FIXED: initial render in IE for large number of rows
Browse files Browse the repository at this point in the history
- CHANGED:  added a 3-row min buffer back in
  • Loading branch information
mleibman committed Jun 28, 2010
1 parent 3378113 commit 78507d2
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions slick.grid.js
Expand Up @@ -252,11 +252,11 @@ if (!jQuery.fn.drag) {

// scroller
var maxSupportedCssHeight; // browser's breaking point
var th = 1000000000; // virtual height
var h = 1000000; // real scrollable height
var ph = h / 100; // page height
var n = Math.floor(th / ph); // number of pages
var cj = (th - h) / (n - 1); // "jumpiness" coefficient
var th; // virtual height
var h; // real scrollable height
var ph; // page height
var n; // number of pages
var cj; // "jumpiness" coefficient

var page = 0; // current page
var offset=0; // current page offset
Expand Down Expand Up @@ -463,7 +463,7 @@ if (!jQuery.fn.drag) {

div.remove();
return supportedHeight;
}
}

// TODO: this is static. need to handle page mutation.
function bindAncestorScrollEvents() {
Expand Down Expand Up @@ -874,7 +874,7 @@ if (!jQuery.fn.drag) {
if ($style[0].styleSheet) { // IE
$style[0].styleSheet.cssText = rules.join("");
}
else {
else {
$style[0].appendChild(document.createTextNode(rules.join(" ")));
}

Expand Down Expand Up @@ -1114,7 +1114,7 @@ if (!jQuery.fn.drag) {

function onNearScroll() {
prevScrollTop = scrollTop;
scrollTo(scrollTop + offset);
scrollTo(scrollTop + offset);
}

function onJump() {
Expand Down Expand Up @@ -1306,7 +1306,7 @@ if (!jQuery.fn.drag) {
$viewport.height(
$container.innerHeight() -
$headerScroller.outerHeight() -
(options.showSecondaryHeaderRow ? $secondaryHeaderScroller.outerHeight() : 0));
(options.showSecondaryHeaderRow ? $secondaryHeaderScroller.outerHeight() : 0));
}

viewportW = $viewport.innerWidth();
Expand Down Expand Up @@ -1335,7 +1335,6 @@ if (!jQuery.fn.drag) {

function updateRowCount() {
var newRowCount = gridDataGetLength() + (options.enableAddRow?1:0) + (options.leaveSpaceForNewRows?numVisibleRows-1:0);

var oldH = h;

th = Math.max(options.rowHeight * newRowCount, viewportH - scrollbarDimensions.height);
Expand All @@ -1353,7 +1352,7 @@ if (!jQuery.fn.drag) {
cj = (th - h) / (n - 1);
}

if (h != oldH) {
if (h !== oldH) {
$canvas.css("height",h);
scrollTop = $viewport[0].scrollTop;
}
Expand Down Expand Up @@ -1387,11 +1386,20 @@ if (!jQuery.fn.drag) {
function getRenderedRange() {
var range = getVisibleRange();
var buffer = Math.round(viewportH/options.rowHeight);
var minBuffer = 3;

if (scrollDir == -1)
if (scrollDir == -1) {
range.top -= buffer;
else if (scrollDir == 1)
range.bottom += minBuffer;
}
else if (scrollDir == 1) {
range.top -= minBuffer;
range.bottom += buffer;
}
else {
range.top -= minBuffer;
range.bottom += minBuffer;
}

range.top = Math.max(0,range.top);
range.bottom = Math.min(options.enableAddRow ? gridDataGetLength() : gridDataGetLength() - 1,range.bottom);
Expand Down Expand Up @@ -1450,7 +1458,7 @@ if (!jQuery.fn.drag) {

function updateRowPositions() {
for (var row in rowsCache) {
rowsCache[row].style.top = (row*options.rowHeight-offset) + "px";
rowsCache[row].style.top = (row*options.rowHeight-offset) + "px";
}
}

Expand Down Expand Up @@ -1575,7 +1583,7 @@ if (!jQuery.fn.drag) {

toggleCellClass(4);
}
}
}

//////////////////////////////////////////////////////////////////////////////////////////////
// Interactivity
Expand Down Expand Up @@ -1826,7 +1834,7 @@ if (!jQuery.fn.drag) {

//////////////////////////////////////////////////////////////////////////////////////////////
// Cell switching

function resetCurrentCell() {
setSelectedCell(null,false,false);
}
Expand All @@ -1853,7 +1861,7 @@ if (!jQuery.fn.drag) {
else
currentCellNode.focus();
}

function setSelectedCell(newCell,editMode,doPaging) {
if (currentCellNode !== null) {
makeSelectedCellNormal();
Expand Down Expand Up @@ -2003,7 +2011,7 @@ if (!jQuery.fn.drag) {
currentEditor.loadValue(item);

serializedEditorValue = currentEditor.serializeValue();

if (currentEditor.position)
handleCurrentCellPositionChange();
}
Expand Down Expand Up @@ -2195,7 +2203,7 @@ if (!jQuery.fn.drag) {
if (!columns[cell].unselectable && !columns[cell].hidden) {
newCell = $(rowsCache[row]).children().eq(cell)[0];
}

// if selecting the 'add new' row, start editing right away
setSelectedCellAndRow(newCell, forceEdit || (row === data.length) || options.autoEdit, false);

Expand Down Expand Up @@ -2235,7 +2243,7 @@ if (!jQuery.fn.drag) {
function commitCurrentEdit() {
var item = gridDataGetItem(currentRow);
var column = columns[currentCell];

if (currentEditor) {
if (currentEditor.isValueChanged()) {
var validationResults = currentEditor.validate();
Expand All @@ -2257,7 +2265,7 @@ if (!jQuery.fn.drag) {
updateRow(this.row);
}
};

if (options.editCommandHandler) {
makeSelectedCellNormal();
options.editCommandHandler(item,column,editCommand);
Expand Down Expand Up @@ -2410,4 +2418,4 @@ if (!jQuery.fn.drag) {
GlobalEditorLock: new EditorLock()
}
});
}(jQuery));
}(jQuery));

0 comments on commit 78507d2

Please sign in to comment.