@@ -928,6 +928,31 @@ describe('CdkVirtualScrollViewport', () => {
928928 expect ( testComponent . trackBy ) . toHaveBeenCalled ( ) ;
929929 } ) ) ;
930930 } ) ;
931+
932+ describe ( 'with append only' , ( ) => {
933+ let fixture : ComponentFixture < VirtualScrollWithAppendOnly > ;
934+ let testComponent : VirtualScrollWithAppendOnly ;
935+ let viewport : CdkVirtualScrollViewport ;
936+
937+ beforeEach ( waitForAsync ( ( ) => {
938+ TestBed . configureTestingModule ( {
939+ imports : [ ScrollingModule , CommonModule ] ,
940+ declarations : [ VirtualScrollWithAppendOnly ] ,
941+ } ) . compileComponents ( ) ;
942+ fixture = TestBed . createComponent ( VirtualScrollWithAppendOnly ) ;
943+ testComponent = fixture . componentInstance ;
944+ viewport = testComponent . viewport ;
945+ } ) ) ;
946+
947+ it ( 'should override rendered range start' , fakeAsync ( ( ) => {
948+ finishInit ( fixture ) ;
949+ viewport . setRenderedRange ( { start : 2 , end : 3 } ) ;
950+ fixture . detectChanges ( ) ;
951+ flush ( ) ;
952+
953+ expect ( viewport . getRenderedRange ( ) ) . toEqual ( { start : 0 , end : 3 } ) ;
954+ } ) ) ;
955+ } ) ;
931956} ) ;
932957
933958
@@ -1182,3 +1207,36 @@ class DelayedInitializationVirtualScroll {
11821207 trackBy = jasmine . createSpy ( 'trackBy' ) . and . callFake ( ( item : unknown ) => item ) ;
11831208 renderVirtualFor = false ;
11841209}
1210+
1211+ @Component ( {
1212+ template : `
1213+ <cdk-virtual-scroll-viewport appendOnly itemSize="50">
1214+ <div class="item" *cdkVirtualFor="let item of items">{{item}}</div>
1215+ </cdk-virtual-scroll-viewport>
1216+ ` ,
1217+ styles : [ `
1218+ .cdk-virtual-scroll-content-wrapper {
1219+ display: flex;
1220+ flex-direction: column;
1221+ }
1222+
1223+ .cdk-virtual-scroll-viewport {
1224+ width: 200px;
1225+ height: 200px;
1226+ background-color: #f5f5f5;
1227+ }
1228+
1229+ .item {
1230+ width: 100%;
1231+ height: 50px;
1232+ box-sizing: border-box;
1233+ border: 1px dashed #ccc;
1234+ }
1235+ ` ] ,
1236+ encapsulation : ViewEncapsulation . None
1237+ } )
1238+ class VirtualScrollWithAppendOnly {
1239+ @ViewChild ( CdkVirtualScrollViewport , { static : true } ) viewport : CdkVirtualScrollViewport ;
1240+ itemSize = 50 ;
1241+ items = Array ( 20000 ) . fill ( 0 ) . map ( ( _ , i ) => i ) ;
1242+ }
0 commit comments