Skip to content

Commit

Permalink
fix: remove debounce to avoid horizontal scroll slowness, fixes #789
Browse files Browse the repository at this point in the history
- this PR simply rolls back PR #722
  • Loading branch information
ghiscoding committed Jun 30, 2023
1 parent b367209 commit 6be4313
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 44 deletions.
18 changes: 0 additions & 18 deletions slick.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,23 +567,6 @@
return elm;
}

/**
* Debounce to delay JS callback execution, a wait of (-1) could be provided to execute callback without delay.
* @param {Function} callback - callback method to execute
* @param {Number} wait - delay to wait before execution or -1 delay
*/
function debounce(callback, wait) {
let timeoutId = null;
return (...args) => {
if (wait >= 0) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => callback.apply(null, args), wait);
} else {
callback.apply(null);
}
};
}

function emptyElement(element) {
if (element && element.firstChild) {
while (element.firstChild) {
Expand Down Expand Up @@ -889,7 +872,6 @@
"EditorLock": EditorLock,
"BindingEventService": BindingEventService,
"Utils": {
"debounce": debounce,
"extend": extend,
"calculateAvailableSpace": calculateAvailableSpace,
"createDomElement": createDomElement,
Expand Down
48 changes: 22 additions & 26 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ if (typeof Slick === "undefined") {
viewportMinWidthPx: undefined,
viewportMaxWidthPx: undefined,
suppressCssChangesOnHiddenInit: false,
scrollDebounceDelay: -1, // add a scroll delay to avoid screen flickering, -1 to disable delay
ffMaxSupportedCssHeight: 6000000,
maxSupportedCssHeight: 1000000000,
sanitizer: undefined, // sanitize function, built in basic sanitizer is: Slick.RegexSanitizer(dirtyHtml)
Expand Down Expand Up @@ -4356,34 +4355,31 @@ if (typeof Slick === "undefined") {
prevScrollLeft = scrollLeft;

// adjust scroll position of all div containers when scrolling the grid
// user can optionally provide "scrollDebounceDelay" grid option if flickering are a problem
utils.debounce(() => {
_viewportScrollContainerX.scrollLeft = scrollLeft;
_headerScrollContainer.scrollLeft = scrollLeft;
_topPanelScrollers[0].scrollLeft = scrollLeft;
if (options.createFooterRow) {
_footerRowScrollContainer.scrollLeft = scrollLeft;
}
if (options.createPreHeaderPanel) {
if (hasFrozenColumns()) {
_preHeaderPanelScrollerR.scrollLeft = scrollLeft;
} else {
_preHeaderPanelScroller.scrollLeft = scrollLeft;
}
}

_viewportScrollContainerX.scrollLeft = scrollLeft;
_headerScrollContainer.scrollLeft = scrollLeft;
_topPanelScrollers[0].scrollLeft = scrollLeft;
if (options.createFooterRow) {
_footerRowScrollContainer.scrollLeft = scrollLeft;
}
if (options.createPreHeaderPanel) {
if (hasFrozenColumns()) {
if (hasFrozenRows) {
_viewportTopR.scrollLeft = scrollLeft;
}
_headerRowScrollerR.scrollLeft = scrollLeft; // right header row scrolling with frozen grid
_preHeaderPanelScrollerR.scrollLeft = scrollLeft;
} else {
if (hasFrozenRows) {
_viewportTopL.scrollLeft = scrollLeft;
}
_headerRowScrollerL.scrollLeft = scrollLeft; // left header row scrolling with regular grid
_preHeaderPanelScroller.scrollLeft = scrollLeft;
}
}, options.scrollDebounceDelay)();
}

if (hasFrozenColumns()) {
if (hasFrozenRows) {
_viewportTopR.scrollLeft = scrollLeft;
}
_headerRowScrollerR.scrollLeft = scrollLeft; // right header row scrolling with frozen grid
} else {
if (hasFrozenRows) {
_viewportTopL.scrollLeft = scrollLeft;
}
_headerRowScrollerL.scrollLeft = scrollLeft; // left header row scrolling with regular grid
}
}

// autoheight suppresses vertical scrolling, but editors can create a div larger than
Expand Down

0 comments on commit 6be4313

Please sign in to comment.