@@ -891,6 +891,52 @@ describe('IgxVirtual directive - simple template', () => {
891
891
chunkSize = firstRecChildren . length ;
892
892
expect ( chunkSize ) . toEqual ( 10 ) ;
893
893
} ) ;
894
+ it ( 'should update horizontal scroll offsets if igxForOf changes. ' , ( ) => {
895
+ const fix = TestBed . createComponent ( HorizontalVirtualComponent ) ;
896
+ fix . componentRef . hostView . detectChanges ( ) ;
897
+ fix . detectChanges ( ) ;
898
+ fix . componentInstance . width = '500px' ;
899
+ fix . componentInstance . cols = [
900
+ { field : '1' , width : 100 } ,
901
+ { field : '2' , width : 200 } ,
902
+ { field : '3' , width : 200 } ,
903
+ { field : '4' , width : 200 } ,
904
+ { field : '5' , width : 300 }
905
+ ] ;
906
+ fix . componentRef . hostView . detectChanges ( ) ;
907
+ fix . detectChanges ( ) ;
908
+ const displayContainer = fix . nativeElement . querySelector ( 'igx-display-container' ) ;
909
+
910
+ fix . componentInstance . scrollLeft ( 50 ) ;
911
+
912
+ fix . detectChanges ( ) ;
913
+
914
+ expect ( parseInt ( displayContainer . style . left , 10 ) ) . toEqual ( - 50 ) ;
915
+
916
+ fix . componentInstance . cols = [
917
+ { field : '1' , width : 100 }
918
+ ] ;
919
+ fix . detectChanges ( ) ;
920
+
921
+ expect ( parseInt ( displayContainer . style . left , 10 ) ) . toEqual ( 0 ) ;
922
+
923
+ } ) ;
924
+ it ( 'should update vertical scroll offsets if igxForOf changes. ' , ( done ) => {
925
+ const fix = TestBed . createComponent ( VerticalVirtualComponent ) ;
926
+ fix . componentRef . hostView . detectChanges ( ) ;
927
+ fix . detectChanges ( ) ;
928
+ fix . componentInstance . scrollTop ( 5 ) ;
929
+ fix . detectChanges ( ) ;
930
+ const displayContainer = fix . nativeElement . querySelector ( 'igx-display-container' ) ;
931
+
932
+ expect ( parseInt ( displayContainer . style . top , 10 ) ) . toEqual ( - 5 ) ;
933
+ fix . componentInstance . data = [ { '1' : 1 , '2' : 2 , '3' : 3 , '4' : 4 } ] ;
934
+ fix . detectChanges ( ) ;
935
+ setTimeout ( ( ) => {
936
+ expect ( parseInt ( displayContainer . style . top , 10 ) ) . toEqual ( 0 ) ;
937
+ done ( ) ;
938
+ } , 10 ) ;
939
+ } ) ;
894
940
} ) ;
895
941
896
942
/** igxFor for testing */
0 commit comments