@@ -11,7 +11,7 @@ import { MultiColumnHeadersComponent } from '../../test-utils/grid-samples.spec'
1111import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1212import { IgxCellHeaderTemplateDirective , IgxCellTemplateDirective } from '../columns/templates.directive' ;
1313import { IgxAvatarComponent } from '../../avatar/avatar.component' ;
14- import { IColumnResizeEventArgs , IgxColumnComponent } from '../public_api' ;
14+ import { IColumnResizeEventArgs , IgxColumnComponent , IgxGridToolbarComponent , IgxGridToolbarTitleComponent } from '../public_api' ;
1515import { Size } from "../common/enums" ;
1616import { setElementSize } from '../../test-utils/helper-utils.spec' ;
1717import { IgxColumnResizerDirective } from '../resizing/resizer.directive' ;
@@ -903,6 +903,65 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
903903 expect ( firstRowCells . length ) . toEqual ( 11 ) ;
904904 } ) ) ;
905905 } ) ;
906+
907+ describe ( 'Resizer tests: ' , ( ) => {
908+ let fixture : ComponentFixture < any > ;
909+ let grid : IgxGridComponent ;
910+
911+ beforeEach ( fakeAsync ( ( ) => {
912+ fixture = TestBed . createComponent ( ResizableColumnsWithToolbarComponent ) ;
913+ fixture . detectChanges ( ) ;
914+ grid = fixture . componentInstance . grid ;
915+ } ) ) ;
916+
917+ it ( 'should align the resizer top with the grid header top' , fakeAsync ( ( ) => {
918+ grid . nativeElement . style . marginTop = '40px' ;
919+ fixture . detectChanges ( ) ;
920+ const headers = GridFunctions . getColumnHeaders ( fixture ) ;
921+ const headerResArea = GridFunctions . getHeaderResizeArea ( headers [ 0 ] ) . nativeElement ;
922+
923+ const headerRectTop = headerResArea . getBoundingClientRect ( ) . top ;
924+
925+ UIInteractions . simulateMouseEvent ( 'mousedown' , headerResArea , 100 , 15 ) ;
926+ tick ( 200 ) ;
927+ fixture . detectChanges ( ) ;
928+
929+ const resizer = GridFunctions . getResizer ( fixture ) . nativeElement ;
930+ expect ( resizer ) . toBeDefined ( ) ;
931+
932+ const resizerRectTop = resizer . getBoundingClientRect ( ) . top ;
933+ UIInteractions . simulateMouseEvent ( 'mousemove' , resizer , 250 , 15 ) ;
934+ UIInteractions . simulateMouseEvent ( 'mouseup' , resizer , 250 , 15 ) ;
935+ fixture . detectChanges ( ) ;
936+
937+
938+ expect ( Math . abs ( resizerRectTop - headerRectTop ) ) . toBeLessThanOrEqual ( 1 ) ;
939+ } ) ) ;
940+
941+ it ( 'should align the resizer top with the grid header top when grid is scaled' , fakeAsync ( ( ) => {
942+ grid . nativeElement . style . transform = 'scale(0.6)' ;
943+ fixture . detectChanges ( ) ;
944+
945+ const headers = GridFunctions . getColumnHeaders ( fixture ) ;
946+ const headerResArea = GridFunctions . getHeaderResizeArea ( headers [ 1 ] ) . nativeElement ;
947+ const headerRectTop = headerResArea . getBoundingClientRect ( ) . top ;
948+
949+ // Trigger resize to show resizer
950+ UIInteractions . simulateMouseEvent ( 'mousedown' , headerResArea , 153 , 0 ) ;
951+ tick ( 200 ) ;
952+ fixture . detectChanges ( ) ;
953+
954+ const resizer = GridFunctions . getResizer ( fixture ) . nativeElement ;
955+ expect ( resizer ) . toBeDefined ( ) ;
956+
957+ const resizerRectTop = resizer . getBoundingClientRect ( ) . top ;
958+
959+ UIInteractions . simulateMouseEvent ( 'mouseup' , resizer , 200 , 5 ) ;
960+ fixture . detectChanges ( ) ;
961+
962+ expect ( Math . abs ( resizerRectTop - headerRectTop ) ) . toBeLessThanOrEqual ( 1 ) ;
963+ } ) ) ;
964+ } ) ;
906965} ) ;
907966
908967@Component ( {
@@ -915,6 +974,18 @@ export class ResizableColumnsComponent {
915974 public data = SampleTestData . personIDNameRegionData ( ) ;
916975}
917976
977+ @Component ( {
978+ template : GridTemplateStrings . declareGrid ( `width="500px" height="300px"` , `` ,
979+ '<igx-grid-toolbar><igx-grid-toolbar-title>Grid Toolbar</igx-grid-toolbar-title></igx-grid-toolbar>' +
980+ ColumnDefinitions . resizableThreeOfFour ) ,
981+ imports : [ IgxGridComponent , IgxColumnComponent , IgxGridToolbarComponent , IgxGridToolbarTitleComponent ]
982+ } )
983+ export class ResizableColumnsWithToolbarComponent {
984+ @ViewChild ( IgxGridComponent , { static : true } ) public grid : IgxGridComponent ;
985+
986+ public data = SampleTestData . personIDNameRegionData ( ) ;
987+ }
988+
918989@Component ( {
919990 template : GridTemplateStrings . declareGrid ( `width="618px" height="600px"` , `` , `<igx-column [field]="'Released'" [pinned]="true" width="100px" dataType="boolean" [resizable]="true"></igx-column>
920991 <igx-column [field]="'ReleaseDate'" [pinned]="true" width="100px" dataType="date" [resizable]="true"
0 commit comments