@@ -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' ;
@@ -899,6 +899,65 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
899899 expect ( firstRowCells . length ) . toEqual ( 11 ) ;
900900 } ) ) ;
901901 } ) ;
902+
903+ describe ( 'Resizer tests: ' , ( ) => {
904+ let fixture : ComponentFixture < any > ;
905+ let grid : IgxGridComponent ;
906+
907+ beforeEach ( fakeAsync ( ( ) => {
908+ fixture = TestBed . createComponent ( ResizableColumnsWithToolbarComponent ) ;
909+ fixture . detectChanges ( ) ;
910+ grid = fixture . componentInstance . grid ;
911+ } ) ) ;
912+
913+ it ( 'should align the resizer top with the grid header top' , fakeAsync ( ( ) => {
914+ grid . nativeElement . style . marginTop = '40px' ;
915+ fixture . detectChanges ( ) ;
916+ const headers = GridFunctions . getColumnHeaders ( fixture ) ;
917+ const headerResArea = GridFunctions . getHeaderResizeArea ( headers [ 0 ] ) . nativeElement ;
918+
919+ const headerRectTop = headerResArea . getBoundingClientRect ( ) . top ;
920+
921+ UIInteractions . simulateMouseEvent ( 'mousedown' , headerResArea , 100 , 15 ) ;
922+ tick ( 200 ) ;
923+ fixture . detectChanges ( ) ;
924+
925+ const resizer = GridFunctions . getResizer ( fixture ) . nativeElement ;
926+ expect ( resizer ) . toBeDefined ( ) ;
927+
928+ const resizerRectTop = resizer . getBoundingClientRect ( ) . top ;
929+ UIInteractions . simulateMouseEvent ( 'mousemove' , resizer , 250 , 15 ) ;
930+ UIInteractions . simulateMouseEvent ( 'mouseup' , resizer , 250 , 15 ) ;
931+ fixture . detectChanges ( ) ;
932+
933+
934+ expect ( Math . abs ( resizerRectTop - headerRectTop ) ) . toBeLessThanOrEqual ( 1 ) ;
935+ } ) ) ;
936+
937+ it ( 'should align the resizer top with the grid header top when grid is scaled' , fakeAsync ( ( ) => {
938+ grid . nativeElement . style . transform = 'scale(0.6)' ;
939+ fixture . detectChanges ( ) ;
940+
941+ const headers = GridFunctions . getColumnHeaders ( fixture ) ;
942+ const headerResArea = GridFunctions . getHeaderResizeArea ( headers [ 1 ] ) . nativeElement ;
943+ const headerRectTop = headerResArea . getBoundingClientRect ( ) . top ;
944+
945+ // Trigger resize to show resizer
946+ UIInteractions . simulateMouseEvent ( 'mousedown' , headerResArea , 153 , 0 ) ;
947+ tick ( 200 ) ;
948+ fixture . detectChanges ( ) ;
949+
950+ const resizer = GridFunctions . getResizer ( fixture ) . nativeElement ;
951+ expect ( resizer ) . toBeDefined ( ) ;
952+
953+ const resizerRectTop = resizer . getBoundingClientRect ( ) . top ;
954+
955+ UIInteractions . simulateMouseEvent ( 'mouseup' , resizer , 200 , 5 ) ;
956+ fixture . detectChanges ( ) ;
957+
958+ expect ( Math . abs ( resizerRectTop - headerRectTop ) ) . toBeLessThanOrEqual ( 1 ) ;
959+ } ) ) ;
960+ } ) ;
902961} ) ;
903962
904963@Component ( {
@@ -911,6 +970,18 @@ export class ResizableColumnsComponent {
911970 public data = SampleTestData . personIDNameRegionData ( ) ;
912971}
913972
973+ @Component ( {
974+ template : GridTemplateStrings . declareGrid ( `width="500px" height="300px"` , `` ,
975+ '<igx-grid-toolbar><igx-grid-toolbar-title>Grid Toolbar</igx-grid-toolbar-title></igx-grid-toolbar>' +
976+ ColumnDefinitions . resizableThreeOfFour ) ,
977+ imports : [ IgxGridComponent , IgxColumnComponent , IgxGridToolbarComponent , IgxGridToolbarTitleComponent ]
978+ } )
979+ export class ResizableColumnsWithToolbarComponent {
980+ @ViewChild ( IgxGridComponent , { static : true } ) public grid : IgxGridComponent ;
981+
982+ public data = SampleTestData . personIDNameRegionData ( ) ;
983+ }
984+
914985@Component ( {
915986 template : GridTemplateStrings . declareGrid ( `width="618px" height="600px"` , `` , `<igx-column [field]="'Released'" [pinned]="true" width="100px" dataType="boolean" [resizable]="true"></igx-column>
916987 <igx-column [field]="'ReleaseDate'" [pinned]="true" width="100px" dataType="date" [resizable]="true"
0 commit comments