@@ -731,13 +731,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
731731 if ( ! parseInt ( this . scrollComponent . nativeElement . style . height , 10 ) ) {
732732 return ;
733733 }
734-
735- const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
736- const maxRealScrollTop = event . target . children [ 0 ] . scrollHeight - containerSize ;
737- const realPercentScrolled = maxRealScrollTop !== 0 ? event . target . scrollTop / maxRealScrollTop : 0 ;
738734 if ( ! this . _bScrollInternal ) {
739- const maxVirtScrollTop = this . _virtHeight - containerSize ;
740- this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
735+ this . _calcVirtualScrollTop ( event . target . scrollTop ) ;
741736 } else {
742737 this . _bScrollInternal = false ;
743738 }
@@ -1306,11 +1301,25 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
13061301 }
13071302 private _updateVScrollOffset ( ) {
13081303 let scrollOffset = 0 ;
1304+ let currentScrollTop = this . scrollPosition ;
1305+ if ( this . _virtHeightRatio !== 1 ) {
1306+ this . _calcVirtualScrollTop ( this . scrollPosition ) ;
1307+ currentScrollTop = this . _virtScrollTop ;
1308+ }
13091309 const vScroll = this . scrollComponent . nativeElement ;
13101310 scrollOffset = vScroll && this . scrollComponent . size ?
1311- this . scrollPosition - this . sizesCache [ this . state . startIndex ] : 0 ;
1311+ currentScrollTop - this . sizesCache [ this . state . startIndex ] : 0 ;
13121312 this . dc . instance . _viewContainer . element . nativeElement . style . top = - ( scrollOffset ) + 'px' ;
13131313 }
1314+
1315+ protected _calcVirtualScrollTop ( scrollTop : number ) {
1316+ const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
1317+ const maxRealScrollTop = this . scrollComponent . size - containerSize ;
1318+ const realPercentScrolled = maxRealScrollTop !== 0 ? scrollTop / maxRealScrollTop : 0 ;
1319+ const maxVirtScrollTop = this . _virtHeight - containerSize ;
1320+ this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1321+ }
1322+
13141323 private _updateHScrollOffset ( ) {
13151324 let scrollOffset = 0 ;
13161325 scrollOffset = this . scrollComponent . nativeElement &&
@@ -1581,13 +1590,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
15811590 if ( ! parseInt ( this . scrollComponent . nativeElement . style . height , 10 ) ) {
15821591 return ;
15831592 }
1584-
1585- const containerSize = parseInt ( this . igxForContainerSize , 10 ) ;
1586- const maxRealScrollTop = event . target . children [ 0 ] . scrollHeight - containerSize ;
1587- const realPercentScrolled = maxRealScrollTop !== 0 ? event . target . scrollTop / maxRealScrollTop : 0 ;
15881593 if ( ! this . _bScrollInternal ) {
1589- const maxVirtScrollTop = this . _virtHeight - containerSize ;
1590- this . _virtScrollTop = realPercentScrolled * maxVirtScrollTop ;
1594+ this . _calcVirtualScrollTop ( event . target . scrollTop ) ;
15911595 } else {
15921596 this . _bScrollInternal = false ;
15931597 }
0 commit comments