Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
* and do proper cleanup.
*/

//function took from underscore.js
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};

// make sure required JavaScript modules are loaded
if (typeof jQuery === "undefined") {
throw "SlickGrid requires jquery module to be loaded";
Expand Down Expand Up @@ -1941,7 +1957,7 @@ if (typeof Slick === "undefined") {
}
}

function render() {
var render = debounce(function(){
if (!initialized) { return; }
var visible = getVisibleRange();
var rendered = getRenderedRange();
Expand All @@ -1964,7 +1980,7 @@ if (typeof Slick === "undefined") {
lastRenderedScrollTop = scrollTop;
lastRenderedScrollLeft = scrollLeft;
h_render = null;
}
}, 250);

function handleHeaderRowScroll() {
var scrollLeft = $headerRowScroller[0].scrollLeft;
Expand Down