Skip to content

Commit

Permalink
fix: shift+mousewheel should scroll horizontally (#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Jan 11, 2025
1 parent 38a7f81 commit a04fb21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/common/src/core/__tests__/slickGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4015,6 +4015,7 @@ describe('SlickGrid core file', () => {
grid.scrollCellIntoView(1, 2, true);

const mouseEvent = new Event('mousewheel');
Object.defineProperty(mouseEvent, 'shiftKey', { writable: true, value: true });
const mousePreventSpy = vi.spyOn(mouseEvent, 'preventDefault');
const onViewportChangedSpy = vi.spyOn(grid.onViewportChanged, 'notify');
const viewportTopLeftElm = container.querySelector('.slick-viewport-top.slick-viewport-left') as HTMLDivElement;
Expand Down
8 changes: 6 additions & 2 deletions packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5133,8 +5133,12 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

protected handleMouseWheel(e: MouseEvent, _delta: number, deltaX: number, deltaY: number): void {
this.scrollHeight = this._viewportScrollContainerY.scrollHeight;
this.scrollTop = Math.max(0, this._viewportScrollContainerY.scrollTop - deltaY * this._options.rowHeight!);
this.scrollLeft = this._viewportScrollContainerX.scrollLeft + deltaX * 10;
if (e.shiftKey) {
this.scrollLeft = this._viewportScrollContainerX.scrollLeft + deltaX * 10;
} else {
this.scrollTop = Math.max(0, this._viewportScrollContainerY.scrollTop - deltaY * this._options.rowHeight!);
this.scrollLeft = this._viewportScrollContainerX.scrollLeft + deltaX * 10;
}
const handled = this._handleScroll('mousewheel');
if (handled) {
e.preventDefault();
Expand Down

0 comments on commit a04fb21

Please sign in to comment.