Skip to content

Commit

Permalink
feat: add enableMouseWheelScrollHandler option to allow dynamic load (#…
Browse files Browse the repository at this point in the history
…555)

* feat: add enableMouseWheelScrollHandler option to allow dynamic load
- when using TypeScript, we must always import the mousewheel jquery lib even if we don't need it because TypeScript does not yet support dynamic import. So providing a grid option to only use the mousewheel handler when we really want it is the only bulletproof way to only use that handler only when we really need it (typically when using a frozen grid)
- ref Angular-Slickgrid [issue](ghiscoding/Angular-Slickgrid#618)

* refactor: dynamically add mousewheel scrolling handler on setOptions
  • Loading branch information
ghiscoding committed Nov 27, 2020
1 parent 708b070 commit 5077d31
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if (typeof Slick === "undefined") {
minRowBuffer: 3,
emulatePagingWhenScrolling: true, // when scrolling off bottom of viewport, place new row at top of viewport
editorCellNavOnLRKeys: false,
enableMouseWheelScrollHandler: true,
doPaging: true,
autosizeColsMode: Slick.GridAutosizeColsMode.LegacyOff,
autosizeColPaddingPx: 4,
Expand Down Expand Up @@ -567,7 +568,7 @@ if (typeof Slick === "undefined") {
$viewport
.on("scroll", handleScroll);

if (jQuery.fn.mousewheel) {
if (jQuery.fn.mousewheel && options.enableMouseWheelScrollHandler) {
$viewport.on("mousewheel", handleMouseWheel);
}

Expand Down Expand Up @@ -2921,6 +2922,13 @@ if (typeof Slick === "undefined") {
if (!suppressColumnSet) {
setColumns(treeColumns.extractColumns());
}

if (options.enableMouseWheelScrollHandler && $viewport && jQuery.fn.mousewheel) {
var viewportEvents = $._data($viewport[0], "events");
if (!viewportEvents || !viewportEvents.mousewheel) {
$viewport.on("mousewheel", handleMouseWheel);
}
}
}

function validateAndEnforceOptions() {
Expand Down

0 comments on commit 5077d31

Please sign in to comment.