Skip to content

Commit 2243c89

Browse files
MKirovaMayaKirova
authored andcommitted
fix(igxFor): Ensure that when scrollHeight is same as container size we do not divide by 0.
1 parent 39b9431 commit 2243c89

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
679679

680680
const containerSize = parseInt(this.igxForContainerSize, 10);
681681
const maxRealScrollTop = event.target.children[0].scrollHeight - containerSize;
682-
const realPercentScrolled = event.target.scrollTop / maxRealScrollTop;
682+
const realPercentScrolled = maxRealScrollTop !== 0 ? event.target.scrollTop / maxRealScrollTop : 0;
683683
if (!this._bScrollInternal) {
684684
const maxVirtScrollTop = this._virtHeight - containerSize;
685685
this._virtScrollTop = realPercentScrolled * maxVirtScrollTop;
@@ -1512,7 +1512,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15121512

15131513
const containerSize = parseInt(this.igxForContainerSize, 10);
15141514
const maxRealScrollTop = event.target.children[0].scrollHeight - containerSize;
1515-
const realPercentScrolled = event.target.scrollTop / maxRealScrollTop;
1515+
const realPercentScrolled = maxRealScrollTop !== 0 ? event.target.scrollTop / maxRealScrollTop : 0;
15161516
if (!this._bScrollInternal) {
15171517
const maxVirtScrollTop = this._virtHeight - containerSize;
15181518
this._virtScrollTop = realPercentScrolled * maxVirtScrollTop;

0 commit comments

Comments
 (0)