Skip to content

Commit a90b14c

Browse files
authored
Merge pull request #7567 from IgniteUI/fix-7351-9.1.x
fix(igxForOf): Fix scrolling too much with trackpad on firefox MacOS.
2 parents ebf4943 + 503e753 commit a90b14c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

projects/igniteui-angular/src/lib/directives/scroll-inertia/scroll_inertia.directive.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class IgxScrollInertiaDirective implements OnInit, OnDestroy {
6262
private _nextX;
6363
private _nextY;
6464
private parentElement;
65+
private baseDeltaMultiplier = 1 / 120;
66+
private firefoxDeltaMultiplier = 1 / 30;
6567

6668
ngOnInit(): void {
6769
this._zone.runOutsideAngular(() => {
@@ -106,28 +108,30 @@ export class IgxScrollInertiaDirective implements OnInit, OnDestroy {
106108
if (evt.wheelDeltaX) {
107109
/* Option supported on Chrome, Safari, Opera.
108110
/* 120 is default for mousewheel on these browsers. Other values are for trackpads */
109-
scrollDeltaX = -evt.wheelDeltaX / 120;
111+
scrollDeltaX = -evt.wheelDeltaX * this.baseDeltaMultiplier;
110112

111113
if (-minWheelStep < scrollDeltaX && scrollDeltaX < minWheelStep) {
112114
scrollDeltaX = Math.sign(scrollDeltaX) * minWheelStep;
113115
}
114116
} else if (evt.deltaX) {
115117
/* For other browsers that don't provide wheelDelta, use the deltaY to determine direction and pass default values. */
116-
scrollDeltaX = this.calcAxisCoords(evt.deltaX, -1, 1);
118+
const deltaScaledX = evt.deltaX * (evt.deltaMode === 0 ? this.firefoxDeltaMultiplier : 1);
119+
scrollDeltaX = this.calcAxisCoords(deltaScaledX, -1, 1);
117120
}
118121

119122
/** Get delta for the Y axis */
120123
if (evt.wheelDeltaY) {
121124
/* Option supported on Chrome, Safari, Opera.
122125
/* 120 is default for mousewheel on these browsers. Other values are for trackpads */
123-
scrollDeltaY = -evt.wheelDeltaY / 120;
126+
scrollDeltaY = -evt.wheelDeltaY * this.baseDeltaMultiplier;
124127

125128
if (-minWheelStep < scrollDeltaY && scrollDeltaY < minWheelStep) {
126129
scrollDeltaY = Math.sign(scrollDeltaY) * minWheelStep;
127130
}
128131
} else if (evt.deltaY) {
129132
/* For other browsers that don't provide wheelDelta, use the deltaY to determine direction and pass default values. */
130-
scrollDeltaY = this.calcAxisCoords(evt.deltaY, -1, 1);
133+
const deltaScaledY = evt.deltaY * (evt.deltaMode === 0 ? this.firefoxDeltaMultiplier : 1);
134+
scrollDeltaY = this.calcAxisCoords(deltaScaledY, -1, 1);
131135
}
132136
if (scrollDeltaX && this.IgxScrollInertiaDirection === 'horizontal') {
133137
this._scrollToX(

0 commit comments

Comments
 (0)