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

Commit be81bda

Browse files
authored
Merge pull request #25 from Angular-RU/fix/null
Fix/null
2 parents 801ec4c + dc08e7f commit be81bda

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

projects/table-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-ru/ng-table-builder",
3-
"version": "0.33.0",
3+
"version": "0.34.0",
44
"license": "MIT",
55
"bugs": {
66
"url": "https://github.com/Angular-RU/ng-table-builder/issues"

projects/table-builder/src/lib/table/animations/fade.animation.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import { animate, AnimationTriggerMetadata, state, style, transition, trigger }
33
const DEFAULT_TIME_ANIMATION: number = 150;
44

55
export const NGX_ANIMATION: AnimationTriggerMetadata = trigger('fadeAnimation', [
6-
// the "in" style determines the "resting" state of the element when it is visible.
76
state('in', style({ opacity: 1 })),
8-
9-
// fade in when created. this could also be written as transition('void => *')
107
transition(':enter', [style({ opacity: 0 }), animate(DEFAULT_TIME_ANIMATION)]),
11-
12-
// fade out when destroyed. this could also be written as transition('void => *')
13-
transition(':leave', animate(DEFAULT_TIME_ANIMATION, style({ opacity: 0 })))
8+
transition(':leave', animate(0, style({ opacity: 0 })))
149
]);

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export class VirtualForDirective implements OnDestroy {
1111
@Input() public virtualForBufferOffset: number | null = null;
1212
private cache: Map<number, InternalVirtualRef> = new Map();
1313
private _source: TableRow[] = [];
14-
// noinspection JSMismatchedCollectionQueryUpdate
1514
private _indexes: VirtualIndex[] = [];
1615
private createFrameId: number;
1716
private removeFrameId: number;
@@ -35,19 +34,23 @@ export class VirtualForDirective implements OnDestroy {
3534

3635
this._indexes = indexes;
3736
this.removeOldNodes();
38-
this.createNewNodes(indexes);
37+
this.createNewNodes(this._indexes);
38+
}
39+
40+
private get sourceRef(): TableRow[] {
41+
return this._source || [];
3942
}
4043

4144
public ngOnDestroy(): void {
42-
this.view.clear();
4345
window.cancelAnimationFrame(this.createFrameId);
4446
window.cancelAnimationFrame(this.removeFrameId);
47+
this.view.clear();
4548
}
4649

4750
private createNewNodes(indexes: VirtualIndex[]): void {
4851
indexes.forEach(
4952
(index: VirtualIndex): void => {
50-
if (this.virtualForBufferOffset < 0) {
53+
if (this.virtualBufferIsOverloadOrNull) {
5154
this.createEmbeddedViewByIndex(index);
5255
} else {
5356
this.createFrameId = window.requestAnimationFrame(
@@ -70,7 +73,7 @@ export class VirtualForDirective implements OnDestroy {
7073
}
7174

7275
private createEmbeddedViewByIndex(index: VirtualIndex): void {
73-
const row: TableRow = this._source[index.position];
76+
const row: TableRow = this.sourceRef[index.position];
7477
const virtualRef: InternalVirtualRef = this.cache.get(index.position);
7578

7679
if (virtualRef) {
@@ -93,7 +96,7 @@ export class VirtualForDirective implements OnDestroy {
9396

9497
this.virtualForDiffIndexes.forEach(
9598
(index: number): void => {
96-
if (this.virtualForBufferOffset < 0) {
99+
if (this.virtualBufferIsOverloadOrNull) {
97100
this.removeEmbeddedViewByIndex(index);
98101
} else {
99102
this.removeFrameId = window.requestAnimationFrame(
@@ -104,6 +107,10 @@ export class VirtualForDirective implements OnDestroy {
104107
);
105108
}
106109

110+
private get virtualBufferIsOverloadOrNull(): boolean {
111+
return this.virtualForBufferOffset < 0 || !Number.isInteger(this.virtualForBufferOffset);
112+
}
113+
107114
private removeEmbeddedViewByIndex(index: number): void {
108115
const ref: InternalVirtualRef | undefined = this.cache.get(index);
109116
if (ref) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
[class.table-grid__column--filter-enable]="filterTemplate"
8888
(observeVisible)="markVisibleColumn(column, $event)"
8989
>
90-
<div *ngIf="column['visible']">
90+
<div *ngIf="column['visible']" [@fadeAnimation]>
9191
<table-thead
9292
cdkDragHandle
9393
[column-schema]="columnSchema"

0 commit comments

Comments
 (0)