Skip to content

Commit bc532eb

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Adjust scroll position after sizes change for horizontal scrollbar as well.
1 parent ac801f6 commit bc532eb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,9 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
14181418
// should update scroll top/left according to change so that same startIndex is in view
14191419
if (Math.abs(sizeDiff) > 0 && this.scrollPosition > 0) {
14201420
this.recalcUpdateSizes();
1421-
const offset = parseInt(this.dc.instance._viewContainer.element.nativeElement.style.top, 10);
1421+
const offset = this.igxForScrollOrientation === 'horizontal' ?
1422+
parseInt(this.dc.instance._viewContainer.element.nativeElement.style.left, 10) :
1423+
parseInt(this.dc.instance._viewContainer.element.nativeElement.style.top, 10);
14221424
const newSize = this.sizesCache[this.state.startIndex] - offset;
14231425
this.scrollPosition = newSize;
14241426
if (this.scrollPosition !== newSize) {
@@ -1658,8 +1660,10 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
16581660

16591661
protected _updateSizeCache(changes: IterableChanges<T> = null) {
16601662
if (this.igxForScrollOrientation === 'horizontal') {
1661-
this.initSizesCache(this.igxForOf);
1662-
return;
1663+
const oldSize = this.sizesCache[this.sizesCache.length - 1];
1664+
const newSize = this.initSizesCache(this.igxForOf);
1665+
const diff = oldSize - newSize;
1666+
return diff;
16631667
}
16641668

16651669
const oldHeight = this.heightCache.length > 0 ? this.heightCache.reduce((acc, val) => acc + val) : 0;

0 commit comments

Comments
 (0)