Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove debounce to avoid horizontal scroll slowness, fixes #789 #803

Closed
Closed
Show file tree
Hide file tree
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
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