Skip to content

Commit cdc6f66

Browse files
Merge branch 'master' into mkirkova-fix-15113-master
2 parents 72e1fb7 + 4e998bc commit cdc6f66

40 files changed

+167
-98
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ jobs:
6666
fi
6767
- name: Test Elements
6868
run: npm run test:elements
69+
- name: Build Demos
70+
run: npm run build
6971
- name: Bundle Tree-Shake & SSR Test
7072
run: npm run build:bundletest
7173
- name: Publish to coveralls.io

angular.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"sourceMap": true,
3939
"optimization": false,
4040
"namedChunks": true,
41-
"aot": false,
4241
"stylePreprocessorOptions": {
4342
"includePaths": [
4443
"node_modules"

projects/igniteui-angular/src/lib/grids/grid/column-resizing.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IgxAvatarComponent } from '../../avatar/avatar.component';
1616
import { IColumnResizeEventArgs, IgxColumnComponent } from '../public_api';
1717
import { Size } from "../common/enums";
1818
import { setElementSize } from '../../test-utils/helper-utils.spec';
19+
import { IgxColumnResizerDirective } from '../resizing/resizer.directive';
1920

2021
describe('IgxGrid - Deferred Column Resizing #grid', () => {
2122

@@ -133,6 +134,27 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
133134
expect(grid.columnList.get(1).width).toEqual('70px');
134135
}));
135136

137+
it('should calculate correctly resizer position and column width when grid is scaled and zoomed', fakeAsync(() => {
138+
grid.nativeElement.style.transform = 'scale(1.2)';
139+
grid.nativeElement.style.setProperty('zoom', '1.05');
140+
fixture.detectChanges();
141+
headerResArea = GridFunctions.getHeaderResizeArea(headers[1]).nativeElement;
142+
UIInteractions.simulateMouseEvent('mousedown', headerResArea, 153, 0);
143+
tick(200);
144+
fixture.detectChanges();
145+
146+
const resizer = GridFunctions.getResizer(fixture);
147+
const resizerDirective = resizer.componentInstance.resizer as IgxColumnResizerDirective;
148+
const leftSetterSpy = spyOnProperty(resizerDirective, 'left', 'set').and.callThrough();
149+
UIInteractions.simulateMouseEvent('mousemove', resizer.nativeElement, 200, 5);
150+
UIInteractions.simulateMouseEvent('mouseup', resizer.nativeElement, 200, 5);
151+
fixture.detectChanges();
152+
153+
expect(leftSetterSpy).toHaveBeenCalled();
154+
expect(parseInt(leftSetterSpy.calls.mostRecent().args[0].toFixed(0))).toEqual(200);
155+
expect(parseInt(grid.columnList.get(1).headerCell.nativeElement.getBoundingClientRect().width.toFixed(0))).toEqual(173);
156+
}));
157+
136158
it('should be able to resize column to the minWidth < defaultMinWidth', fakeAsync(() => {
137159
const column = grid.getColumnByName('ID');
138160
column.minWidth = 'a';

projects/igniteui-angular/src/lib/grids/resizing/resizer.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
[restrictHResizeMax]="colResizingService.restrictResizeMax"
55
[restrictHResizeMin]="colResizingService.restrictResizeMin"
66
[restrictResizerTop]="restrictResizerTop"
7-
(resizeEnd)="colResizingService.resizeColumn($event)">
7+
(resizeEnd)="colResizingService.resizeColumn($event, resizer.ratio)">
88
</div>

projects/igniteui-angular/src/lib/grids/resizing/resizer.directive.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
4141
@Output() public resize = new Subject<any>();
4242

4343
private _left: number;
44+
private _ratio: number = 1;
4445
private _destroy = new Subject<boolean>();
4546

47+
public get ratio(): number {
48+
return this._ratio;
49+
}
50+
4651
constructor(
4752
public element: ElementRef<HTMLElement>,
4853
@Inject(DOCUMENT) public document,
@@ -56,7 +61,7 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
5661
.pipe(
5762
takeUntil(this._destroy),
5863
takeUntil<MouseEvent>(this.resizeEnd),
59-
map((event) => event.clientX - offset),
64+
map((event) => (event.clientX - offset) / (this._ratio)),
6065
))
6166
)
6267
.subscribe((pos) => {
@@ -113,8 +118,12 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
113118
public onMousedown(event: MouseEvent) {
114119
event.preventDefault();
115120
const parent = this.element.nativeElement.parentElement.parentElement;
116-
117-
this.left = this._left = event.clientX - parent.getBoundingClientRect().left;
121+
const parentRectWidth = parent.getBoundingClientRect().width;
122+
const parentComputedWidth = parseFloat(window.getComputedStyle(parent).width);
123+
if (Math.abs(parentRectWidth - parentComputedWidth) > 1) {
124+
this._ratio = parentRectWidth / parentComputedWidth;
125+
}
126+
this.left = this._left = (event.clientX - parent.getBoundingClientRect().left) / this._ratio;
118127
this.top = (event.target as HTMLElement).getBoundingClientRect().top - parent.getBoundingClientRect().top;
119128

120129
this.resizeStart.next(event);

projects/igniteui-angular/src/lib/grids/resizing/resizing.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class IgxColumnResizingService {
3535
* @hidden
3636
*/
3737
public getColumnHeaderRenderedWidth() {
38-
return this.column.headerCell.nativeElement.getBoundingClientRect().width;
38+
return parseFloat(window.getComputedStyle(this.column.headerCell.nativeElement).width);
3939
}
4040

4141
/**
@@ -101,9 +101,9 @@ export class IgxColumnResizingService {
101101
/**
102102
* Resizes the column regaridng to the column minWidth and maxWidth.
103103
*/
104-
public resizeColumn(event: MouseEvent) {
104+
public resizeColumn(event: MouseEvent, ratio: number = 1) {
105105
this.showResizer = false;
106-
const diff = event.clientX - this.startResizePos;
106+
const diff = (event.clientX - this.startResizePos) / ratio;
107107

108108
const colWidth = this.column.width;
109109
const isPercentageWidth = colWidth && typeof colWidth === 'string' && colWidth.indexOf('%') !== -1;

src/app/action-strip/action-strip.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h5>Grid Pinning Action</h5>
3232
</igx-action-strip>
3333
</igx-grid>
3434
</div>
35-
<button igxButton="outlined" (click)="this.grid1.transactions.commit(this.grid1.data)">Commit</button>
35+
<button igxButton="outlined" (click)="grid1.transactions.commit(grid1.data)">Commit</button>
3636

3737
<div class="sample-column">
3838
<h5>Grid Pinning and Editing Actions</h5>

src/app/action-strip/action-strip.sample.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
IgxActionStripComponent,
88
IgxActionStripMenuItemDirective,
99
IgxButtonDirective,
10-
IgxButtonGroupComponent,
1110
IgxCellTemplateDirective,
1211
IgxColumnComponent,
1312
IgxGridComponent,
@@ -65,7 +64,6 @@ class User {
6564
imports: [
6665
NgIf,
6766
NgFor,
68-
IgxButtonGroupComponent,
6967
IgxButtonDirective,
7068
IgxActionStripComponent,
7169
IgxIconComponent,

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class AppComponent implements OnInit {
292292
name: 'Grid Auto Size'
293293
},
294294
{
295-
link: '/gridDocManager',
295+
link: '/gridDockManager',
296296
icon: 'view_column',
297297
name: 'Grid in DockManager'
298298
},

src/app/app.routes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ import { GridValidationSampleComponent } from './grid-validation/grid-validation
138138
import { GridExportComponent } from './grid-export/grid-export.sample';
139139
import { DividerComponent } from './divider/divider.component';
140140
import { MonthPickerSampleComponent } from './month-picker/month-picker.sample';
141-
import { GridDocManagerSampleComponent } from './docmanager-grid/docmanager-grid.sample';
141+
import { GridDockManagerSampleComponent } from './dockmanager-grid/dockmanager-grid.sample';
142142
import { HoundComponent } from './hound/hound.component';
143143
import { LabelSampleComponent } from "./label/label.sample";
144144
import { GridRecreateSampleComponent } from './grid-re-create/grid-re-create.sample';
@@ -614,8 +614,8 @@ export const appRoutes: Routes = [
614614
component: GridAutoSizeSampleComponent
615615
},
616616
{
617-
path: 'gridDocManager',
618-
component: GridDocManagerSampleComponent
617+
path: 'gridDockManager',
618+
component: GridDockManagerSampleComponent
619619
},
620620
{
621621
path: 'gridFlex',

0 commit comments

Comments
 (0)