@@ -1413,14 +1413,19 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
1413
1413
}
1414
1414
1415
1415
1416
- private _adjustScrollPositionAfterSizeChange ( sizeDiff ) {
1416
+ protected _adjustScrollPositionAfterSizeChange ( sizeDiff ) {
1417
1417
// if data has been changed while container is scrolled
1418
1418
// should update scroll top/left according to change so that same startIndex is in view
1419
1419
if ( Math . abs ( sizeDiff ) > 0 && this . scrollPosition > 0 ) {
1420
1420
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 ) ;
1422
1424
const newSize = this . sizesCache [ this . state . startIndex ] - offset ;
1423
- this . scrollPosition = newSize === this . scrollPosition ? newSize + 1 : newSize ;
1425
+ this . scrollPosition = newSize ;
1426
+ if ( this . scrollPosition !== newSize ) {
1427
+ this . scrollComponent . scrollAmount = newSize ;
1428
+ }
1424
1429
}
1425
1430
}
1426
1431
@@ -1575,8 +1580,11 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
1575
1580
}
1576
1581
this . syncService . setMaster ( this ) ;
1577
1582
this . igxForContainerSize = args . containerSize ;
1578
- this . _updateSizeCache ( changes ) ;
1583
+ const sizeDiff = this . _updateSizeCache ( changes ) ;
1579
1584
this . _applyChanges ( ) ;
1585
+ if ( sizeDiff ) {
1586
+ this . _adjustScrollPositionAfterSizeChange ( sizeDiff ) ;
1587
+ }
1580
1588
this . _updateScrollOffset ( ) ;
1581
1589
this . dataChanged . emit ( ) ;
1582
1590
}
@@ -1652,8 +1660,10 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
1652
1660
1653
1661
protected _updateSizeCache ( changes : IterableChanges < T > = null ) {
1654
1662
if ( this . igxForScrollOrientation === 'horizontal' ) {
1655
- this . initSizesCache ( this . igxForOf ) ;
1656
- 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 ;
1657
1667
}
1658
1668
1659
1669
const oldHeight = this . heightCache . length > 0 ? this . heightCache . reduce ( ( acc , val ) => acc + val ) : 0 ;
@@ -1681,6 +1691,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
1681
1691
}
1682
1692
} ) ;
1683
1693
}
1694
+ return diff ;
1684
1695
}
1685
1696
1686
1697
protected handleCacheChanges ( changes : IterableChanges < T > ) {
0 commit comments