@@ -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 . _calcVirtualHeight ( event . target . scrollTop ) ;
726721 } else {
727722 this . _bScrollInternal = false ;
728723 }
@@ -1289,11 +1284,21 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
12891284 }
12901285 private _updateVScrollOffset ( ) {
12911286 let scrollOffset = 0 ;
1287+ this . _calcVirtualHeight ( this . scrollPosition ) ;
12921288 const vScroll = this . scrollComponent . nativeElement ;
12931289 scrollOffset = vScroll && this . scrollComponent . size ?
12941290 this . _virtScrollTop - this . sizesCache [ this . state . startIndex ] : 0 ;
12951291 this . dc . instance . _viewContainer . element . nativeElement . style . top = - ( scrollOffset ) + 'px' ;
12961292 }
1293+
1294+ protected _calcVirtualHeight ( scrollTop : number ) {
1295+ const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
1296+ const maxRealScrollTop = this . scrollComponent . size - containerSize ;
1297+ const realPercentScrolled = maxRealScrollTop !== 0 ? scrollTop / maxRealScrollTop : 0 ;
1298+ const maxVirtScrollTop = this . _virtHeight - containerSize ;
1299+ this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1300+ }
1301+
12971302 private _updateHScrollOffset ( ) {
12981303 let scrollOffset = 0 ;
12991304 scrollOffset = this . scrollComponent . nativeElement &&
@@ -1564,13 +1569,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15641569 if ( ! parseInt ( this . scrollComponent . nativeElement . style . height , 10 ) ) {
15651570 return ;
15661571 }
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 ;
15711572 if ( ! this . _bScrollInternal ) {
1572- const maxVirtScrollTop = this . _virtHeight - containerSize ;
1573- this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1573+ this . _calcVirtualHeight ( event . target . scrollTop ) ;
15741574 } else {
15751575 this . _bScrollInternal = false ;
15761576 }
0 commit comments