@@ -716,13 +716,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
716716 if ( ! parseInt ( this . scrollComponent . nativeElement . style . height , 10 ) ) {
717717 return ;
718718 }
719-
720- const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
721- const maxRealScrollTop = event . target . children [ 0 ] . scrollHeight - containerSize ;
722- const realPercentScrolled = maxRealScrollTop !== 0 ? event . target . scrollTop / maxRealScrollTop : 0 ;
723719 if ( ! this . _bScrollInternal ) {
724- const maxVirtScrollTop = this . _virtHeight - containerSize ;
725- this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
720+ this . _calcVirtualScrollTop ( event . target . scrollTop ) ;
726721 } else {
727722 this . _bScrollInternal = false ;
728723 }
@@ -1289,11 +1284,25 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
12891284 }
12901285 private _updateVScrollOffset ( ) {
12911286 let scrollOffset = 0 ;
1287+ let currentScrollTop = this . scrollPosition ;
1288+ if ( this . _virtHeightRatio !== 1 ) {
1289+ this . _calcVirtualScrollTop ( this . scrollPosition ) ;
1290+ currentScrollTop = this . _virtScrollTop ;
1291+ }
12921292 const vScroll = this . scrollComponent . nativeElement ;
12931293 scrollOffset = vScroll && this . scrollComponent . size ?
1294- this . scrollPosition - this . sizesCache [ this . state . startIndex ] : 0 ;
1294+ currentScrollTop - this . sizesCache [ this . state . startIndex ] : 0 ;
12951295 this . dc . instance . _viewContainer . element . nativeElement . style . top = - ( scrollOffset ) + 'px' ;
12961296 }
1297+
1298+ protected _calcVirtualScrollTop ( scrollTop : number ) {
1299+ const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
1300+ const maxRealScrollTop = this . scrollComponent . size - containerSize ;
1301+ const realPercentScrolled = maxRealScrollTop !== 0 ? scrollTop / maxRealScrollTop : 0 ;
1302+ const maxVirtScrollTop = this . _virtHeight - containerSize ;
1303+ this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1304+ }
1305+
12971306 private _updateHScrollOffset ( ) {
12981307 let scrollOffset = 0 ;
12991308 scrollOffset = this . scrollComponent . nativeElement &&
@@ -1564,13 +1573,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15641573 if ( ! parseInt ( this . scrollComponent . nativeElement . style . height , 10 ) ) {
15651574 return ;
15661575 }
1567-
1568- const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
1569- const maxRealScrollTop = event . target . children [ 0 ] . scrollHeight - containerSize ;
1570- const realPercentScrolled = maxRealScrollTop !== 0 ? event . target . scrollTop / maxRealScrollTop : 0 ;
15711576 if ( ! this . _bScrollInternal ) {
1572- const maxVirtScrollTop = this . _virtHeight - containerSize ;
1573- this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1577+ this . _calcVirtualScrollTop ( event . target . scrollTop ) ;
15741578 } else {
15751579 this . _bScrollInternal = false ;
15761580 }
0 commit comments