-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
ui-scroll.component.ts
73 lines (64 loc) · 1.98 KB
/
ui-scroll.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {
Component, OnInit, OnDestroy,
TemplateRef, ElementRef,
ChangeDetectionStrategy, ChangeDetectorRef
} from '@angular/core';
import { Workflow } from './component/workflow';
import { Datasource as IDatasource } from './component/interfaces/index';
import { Datasource } from './component/classes/datasource';
import { Item } from './component/classes/item';
const template = `<ng-container *ngIf="isTable"><tr data-sid="backward">
<td><div data-padding-backward></div></td>
</tr><ng-template
*ngFor="let item of items"
[ngTemplateOutlet]="template"
[ngTemplateOutletContext]="{
$implicit: item.data,
index: item.$index,
odd: item.$index % 2,
even: !(item.$index % 2)
}"
></ng-template><tr data-sid="forward">
<td><div data-padding-forward></div></td>
</tr></ng-container><ng-container *ngIf="!isTable"><div data-padding-backward></div><div
*ngFor="let item of items"
[attr.data-sid]="item.nodeId"
[style.position]="item.invisible ? 'fixed' : null"
[style.left]="item.invisible ? '-99999px' : null"
><ng-template
[ngTemplateOutlet]="template"
[ngTemplateOutletContext]="{
$implicit: item.data,
index: item.$index,
odd: item.$index % 2,
even: !(item.$index % 2)
}"
></ng-template></div><div data-padding-forward></div></ng-container>`
/* tslint:disable:component-selector */
@Component({
selector: 'tbody [ui-scroll]',
changeDetection: ChangeDetectionStrategy.OnPush,
template
})
export class UiScrollComponent implements OnInit, OnDestroy {
// come from the directive
public version: string;
public template: TemplateRef<any>;
public datasource: IDatasource | Datasource;
public isTable: boolean;
// use in the template
public items: Array<Item>;
// Component-Workflow integration
public workflow: Workflow;
constructor(
public changeDetector: ChangeDetectorRef,
public elementRef: ElementRef
) {
}
ngOnInit() {
this.workflow = new Workflow(this);
}
ngOnDestroy() {
this.workflow.dispose();
}
}