Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit aa67401

Browse files
authored
Merge pull request #32 from Angular-RU/feat/render
refactor: small fixes
2 parents 5bf0ff7 + 6e4d9f9 commit aa67401

17 files changed

+51
-165
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@angular-ru/ng-table-builder",
3-
"version": "1.3.0",
3+
"version": "1.5.0",
44
"license": "MIT",
55
"bugs": {
66
"url": "https://github.com/Angular-RU/ng-table-builder/issues"
77
},
88
"homepage": "https://github.com/Angular-RU/ng-table-builder/#readme",
99
"peerDependencies": {
10-
"@angular/common": ">=7.2.0 <9.0.0",
11-
"@angular/core": ">=7.2.0 <9.0.0",
12-
"@angular/cdk": ">=7.2.0 <9.0.0",
13-
"@angular/animations": ">=7.2.0 <9.0.0",
10+
"@angular/common": ">=8.0.0 <9.0.0",
11+
"@angular/core": ">=8.0.0 <9.0.0",
12+
"@angular/cdk": ">=8.0.0 <9.0.0",
13+
"@angular/animations": ">=8.0.0 <9.0.0",
1414
"rxjs": ">=6.1.0"
1515
}
1616
}

projects/table-builder/src/lib/table/components/common/modal-view-layer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
8181
public updateView(): void {
8282
detectChanges(this.cd);
8383

84-
this.ngZone.run((): void => {
84+
this.ngZone.runOutsideAngular((): void => {
8585
window.requestAnimationFrame((): void => {
8686
detectChanges(this.cd);
87-
this.app.tick();
8887
this.refresh();
8988
});
9089
});

projects/table-builder/src/lib/table/components/table-tbody/table-tbody.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<div class="total-padding" [style.height.px]="columnVirtualHeight">
22
<ng-container
33
*virtualFor="
4-
let item of viewportInfo.virtualIndexes;
4+
let item of virtualIndexes;
55
originSource: source;
6-
bufferOffset: viewportInfo.bufferOffset;
76
diffIndexes: viewportInfo.diffIndexes;
87
let virtualIndex = virtualIndex
98
"

projects/table-builder/src/lib/table/components/table-tbody/table-tbody.component.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
TableClickEventEmitter,
1919
TableEvent,
2020
TableRow,
21-
ViewPortInfo
21+
ViewPortInfo,
22+
VirtualIndex
2223
} from '../../interfaces/table-builder.external';
2324
import { KeyMap, RecalculatedStatus, TableBrowserEvent } from '../../interfaces/table-builder.internal';
2425
import { getDeepValue } from '../../operators/deep-value';
@@ -45,6 +46,7 @@ export class TableTbodyComponent {
4546
@Input() public recalculated: RecalculatedStatus;
4647
@Input('head-height') public headLineHeight: number;
4748
@Input('viewport-info') public viewportInfo: ViewPortInfo;
49+
@Input('virtual-indexes') public virtualIndexes: VirtualIndex[];
4850
@Input('enable-selection') public enableSelection: boolean;
4951
@Input('enable-filtering') public enableFiltering: boolean;
5052
@Input('table-viewport') public tableViewport: HTMLElement;
@@ -71,13 +73,16 @@ export class TableTbodyComponent {
7173

7274
public openContextMenu(event: MouseEvent, key: string, row: TableRow): void {
7375
if (this.contextMenuTemplate) {
74-
const selectOnlyUnSelectedRow: boolean = this.enableSelection && !this.checkSelectedItem(row);
76+
this.ngZone.run((): void => {
77+
const selectOnlyUnSelectedRow: boolean = this.enableSelection && !this.checkSelectedItem(row);
7578

76-
if (selectOnlyUnSelectedRow) {
77-
this.selection.selectRow(row, event, this.source);
78-
}
79+
if (selectOnlyUnSelectedRow) {
80+
this.selection.selectRow(row, event, this.source);
81+
}
7982

80-
this.contextMenu.openContextMenu(event, key, row);
83+
this.contextMenu.openContextMenu(event, key, row);
84+
this.changed.emit();
85+
});
8186
}
8287
}
8388

projects/table-builder/src/lib/table/config/table-global-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export const TABLE_GLOBAL_OPTIONS: TableGlobalOptions = {
1717
ROW_HEIGHT: 45,
1818
TIME_IDLE: 200,
1919
MIN_BUFFER: 10,
20-
BUFFER_OFFSET: 3
20+
BUFFER_OFFSET: 5
2121
};

projects/table-builder/src/lib/table/directives/auto-height.directive.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@ import { TableRow } from '../interfaces/table-builder.external';
1818
import { Any, BoxView, DynamicHeightOptions } from '../interfaces/table-builder.internal';
1919
import { BORDER_TOB_WITH_BOTTOM, HEAD_TOP, SCROLLBAR_WIDTH } from '../symbols';
2020

21-
const DELAY: number = 100;
22-
const MIN_RESIZE_DELAY: number = 200;
21+
const MIN_RESIZE_DELAY: number = 500;
22+
const RECALCULATE_HEIGHT: number = 100;
2323

2424
@Directive({ selector: '[autoHeight]' })
2525
export class AutoHeightDirective implements OnInit, OnChanges, OnDestroy {
2626
@Input() public autoHeight: Partial<DynamicHeightOptions> = {};
2727
@Input() public tableViewport: Partial<HTMLDivElement> = {};
2828
@Input() public sourceRef: TableRow[] = [];
29-
@Output() public recalculatedHeight: EventEmitter<void> = new EventEmitter();
29+
@Output() public recalculatedHeight: EventEmitter<void> = new EventEmitter(true);
3030
private destroy$: Subject<boolean> = new Subject<boolean>();
3131
private readonly minHeight: number = 0;
32-
private readonly delay: number = DELAY;
3332
private useOnlyAutoViewPort: boolean = false;
3433
private isDirtyCheck: boolean;
3534
private taskId: number;
@@ -156,7 +155,7 @@ export class AutoHeightDirective implements OnInit, OnChanges, OnDestroy {
156155
this.calculateHeight();
157156
this.recalculatedHeight.emit();
158157
}
159-
}, this.delay);
158+
}, RECALCULATE_HEIGHT);
160159
});
161160
}
162161

projects/table-builder/src/lib/table/directives/virtual-for.directive.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import { Directive, EmbeddedViewRef, Input, OnDestroy, TemplateRef, ViewContaine
33
import { InternalVirtualRef, TableRow, VirtualContext, VirtualIndex } from '../interfaces/table-builder.external';
44
import { detectChanges } from '../operators/detect-changes';
55

6-
@Directive({
7-
selector: '[virtualFor][virtualForOf]'
8-
})
6+
@Directive({ selector: '[virtualFor][virtualForOf]' })
97
export class VirtualForDirective implements OnDestroy {
108
@Input() public virtualForDiffIndexes: number[] = [];
11-
@Input() public virtualForBufferOffset: number | null = null;
129
private cache: Map<number, InternalVirtualRef> = new Map();
1310
private _source: TableRow[] = [];
1411
private _indexes: VirtualIndex[] = [];
15-
private createFrameId: number;
12+
private readonly createFrameId: number;
1613
private removeFrameId: number;
1714
private dirty: boolean = false;
1815

@@ -48,13 +45,7 @@ export class VirtualForDirective implements OnDestroy {
4845
}
4946

5047
private createNewNodes(indexes: VirtualIndex[]): void {
51-
indexes.forEach((index: VirtualIndex): void => {
52-
if (this.virtualBufferIsOverloadOrNull) {
53-
this.createEmbeddedViewByIndex(index);
54-
} else {
55-
this.createFrameId = window.requestAnimationFrame((): void => this.createEmbeddedViewByIndex(index));
56-
}
57-
});
48+
(indexes || []).forEach((index: VirtualIndex): void => this.createEmbeddedViewByIndex(index));
5849
}
5950

6051
private createEmbeddedView(row: TableRow, index: VirtualIndex): void {
@@ -91,18 +82,10 @@ export class VirtualForDirective implements OnDestroy {
9182
}
9283

9384
this.virtualForDiffIndexes.forEach((index: number): void => {
94-
if (this.virtualBufferIsOverloadOrNull) {
95-
this.removeEmbeddedViewByIndex(index);
96-
} else {
97-
this.removeFrameId = window.requestAnimationFrame((): void => this.removeEmbeddedViewByIndex(index));
98-
}
85+
this.removeFrameId = window.requestAnimationFrame((): void => this.removeEmbeddedViewByIndex(index));
9986
});
10087
}
10188

102-
private get virtualBufferIsOverloadOrNull(): boolean {
103-
return this.virtualForBufferOffset < 0 || !Number.isInteger(this.virtualForBufferOffset);
104-
}
105-
10689
private removeEmbeddedViewByIndex(index: number): void {
10790
const ref: InternalVirtualRef | undefined = this.cache.get(index);
10891
if (ref) {

projects/table-builder/src/lib/table/interfaces/table-builder.external.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export interface CalculateRange {
106106
end: number;
107107
bufferOffset: number;
108108
force: boolean;
109-
isDownMoved: boolean;
110109
}
111110

112111
export type ProduceDisableFn = ((item: TableRow) => boolean) | null;

projects/table-builder/src/lib/table/styles/cell.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060

6161
&--body {
6262
position: absolute;
63-
will-change: transform;
6463
}
6564

6665
&--custom-cell:not(&--is-model-cell) {
@@ -83,7 +82,6 @@
8382
}
8483

8584
.table-grid__cell--inner-content {
86-
will-change: opacity;
8785
overflow: hidden;
8886
}
8987
}

projects/table-builder/src/lib/table/styles/columns.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
&--sticky-right {
2424
position: sticky;
2525
background: $backgroundColor;
26-
will-change: auto;
2726
z-index: 100;
2827
}
2928

0 commit comments

Comments
 (0)