@worktile/gantt 11.0.2 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.all-contributorsrc +53 -0
- package/.angulardoc.json +4 -0
- package/.circleci/config.yml +17 -0
- package/.coveralls.yml +1 -0
- package/.docgenirc.js +64 -0
- package/.editorconfig +22 -0
- package/.prettierrc +24 -0
- package/.travis.yml +23 -0
- package/CHANGELOG.md +564 -0
- package/Dockerfile +4 -0
- package/LICENSE +21 -0
- package/README.md +116 -13
- package/angular.json +136 -0
- package/docs/guides/basic/components.md +54 -0
- package/docs/guides/basic/event.md +70 -0
- package/docs/guides/basic/index.md +4 -0
- package/docs/guides/basic/style.md +68 -0
- package/docs/guides/basic/type.md +70 -0
- package/docs/guides/basic/usage.md +189 -0
- package/docs/guides/index.md +5 -0
- package/docs/guides/intro/getting-started.md +79 -0
- package/docs/guides/intro/index.md +51 -0
- package/docs/index.md +0 -0
- package/example/browserslist +12 -0
- package/example/src/app/app-routing.module.ts +26 -0
- package/example/src/app/app.component.html +2 -0
- package/example/src/app/app.component.ts +11 -0
- package/example/src/app/app.module.ts +57 -0
- package/example/src/app/components/components.component.html +6 -0
- package/example/src/app/components/components.component.ts +33 -0
- package/example/src/app/configuration/parameters/api/zh-cn.js +350 -0
- package/example/src/app/configuration/parameters/doc/zh-cn.md +5 -0
- package/example/src/app/gantt/gantt.component.html +51 -0
- package/example/src/app/gantt/gantt.component.ts +119 -0
- package/example/src/app/gantt-advanced/component/flat.component.html +30 -0
- package/example/src/app/gantt-advanced/component/flat.component.ts +72 -0
- package/example/src/app/gantt-advanced/component/flat.scss +31 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.html +32 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.ts +34 -0
- package/example/src/app/gantt-advanced/mocks.ts +158 -0
- package/example/src/app/gantt-groups/gantt-groups.component.html +42 -0
- package/example/src/app/gantt-groups/gantt-groups.component.ts +62 -0
- package/example/src/app/gantt-range/gantt-range.component.html +66 -0
- package/example/src/app/gantt-range/gantt-range.component.ts +67 -0
- package/example/src/app/gantt-range/mocks.ts +150 -0
- package/example/src/app/helper.ts +38 -0
- package/example/src/assets/.gitkeep +0 -0
- package/example/src/environments/environment.prod.ts +3 -0
- package/example/src/environments/environment.ts +16 -0
- package/example/src/favicon.ico +0 -0
- package/example/src/index.html +13 -0
- package/example/src/main.ts +12 -0
- package/example/src/polyfills.ts +63 -0
- package/example/src/styles.scss +56 -0
- package/example/tsconfig.app.json +18 -0
- package/nginx.conf +17 -0
- package/package.json +113 -17
- package/packages/gantt/README.md +24 -0
- package/packages/gantt/karma.conf.js +46 -0
- package/packages/gantt/ng-package.json +7 -0
- package/packages/gantt/ng-package.prod.json +7 -0
- package/packages/gantt/package.json +16 -0
- package/packages/gantt/src/class/date-point.ts +14 -0
- package/{class/event.d.ts → packages/gantt/src/class/event.ts} +12 -6
- package/packages/gantt/src/class/group.ts +36 -0
- package/{class/index.d.ts → packages/gantt/src/class/index.ts} +0 -0
- package/packages/gantt/src/class/item.ts +129 -0
- package/packages/gantt/src/class/test/group.spec.ts +21 -0
- package/packages/gantt/src/class/test/item.spec.ts +102 -0
- package/packages/gantt/src/class/view-type.ts +7 -0
- package/packages/gantt/src/components/bar/bar-drag.ts +298 -0
- package/packages/gantt/src/components/bar/bar.component.html +17 -0
- package/packages/gantt/src/components/bar/bar.component.scss +169 -0
- package/packages/gantt/src/components/bar/bar.component.ts +109 -0
- package/packages/gantt/src/components/bar/test/bar.component.spec.ts +54 -0
- package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +196 -0
- package/packages/gantt/src/components/calendar/calendar.component.html +52 -0
- package/packages/gantt/src/components/calendar/calendar.component.scss +77 -0
- package/packages/gantt/src/components/calendar/calendar.component.ts +100 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +6 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +48 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +13 -0
- package/packages/gantt/src/components/icon/icon.component.scss +13 -0
- package/packages/gantt/src/components/icon/icon.component.ts +28 -0
- package/packages/gantt/src/components/icon/icons.ts +86 -0
- package/packages/gantt/src/components/links/links.component.html +19 -0
- package/packages/gantt/src/components/links/links.component.scss +27 -0
- package/packages/gantt/src/components/links/links.component.ts +263 -0
- package/packages/gantt/src/components/main/gantt-main.component.html +35 -0
- package/packages/gantt/src/components/main/gantt-main.component.ts +35 -0
- package/packages/gantt/src/components/range/range.component.html +8 -0
- package/packages/gantt/src/components/range/range.component.scss +35 -0
- package/packages/gantt/src/components/range/range.component.ts +27 -0
- package/packages/gantt/src/components/range/test/range.component.spec.ts +80 -0
- package/packages/gantt/src/components/table/gantt-table.component.html +105 -0
- package/packages/gantt/src/components/table/gantt-table.component.scss +144 -0
- package/packages/gantt/src/components/table/gantt-table.component.ts +166 -0
- package/packages/gantt/src/components/table/test/table.spec.ts +129 -0
- package/packages/gantt/src/gantt-abstract.ts +14 -0
- package/packages/gantt/src/gantt-dom.service.ts +134 -0
- package/packages/gantt/src/gantt-drag-container.ts +73 -0
- package/packages/gantt/src/gantt-item-upper.ts +50 -0
- package/packages/gantt/src/gantt-print.service.ts +104 -0
- package/packages/gantt/src/gantt-upper.ts +289 -0
- package/packages/gantt/src/gantt.component.html +18 -0
- package/packages/gantt/src/gantt.component.scss +77 -0
- package/packages/gantt/src/gantt.component.ts +134 -0
- package/packages/gantt/src/gantt.module.ts +47 -0
- package/packages/gantt/src/gantt.pipe.ts +31 -0
- package/packages/gantt/src/gantt.styles.ts +28 -0
- package/{public-api.d.ts → packages/gantt/src/public-api.ts} +6 -0
- package/packages/gantt/src/root.component.html +12 -0
- package/packages/gantt/src/root.component.ts +121 -0
- package/packages/gantt/src/styles/index.scss +9 -0
- package/packages/gantt/src/styles/variables.scss +46 -0
- package/packages/gantt/src/table/gantt-column.component.ts +25 -0
- package/packages/gantt/src/table/gantt-table.component.ts +14 -0
- package/packages/gantt/src/table/test/table.spec.ts +56 -0
- package/packages/gantt/src/test/gantt.component.spec.ts +404 -0
- package/packages/gantt/src/test/mocks/data.ts +303 -0
- package/packages/gantt/src/test.ts +21 -0
- package/packages/gantt/src/utils/date.ts +276 -0
- package/packages/gantt/src/utils/helpers.ts +66 -0
- package/packages/gantt/src/utils/test/date.spec.ts +105 -0
- package/packages/gantt/src/utils/test/helpers.spec.ts +73 -0
- package/packages/gantt/src/utils/testing.ts +64 -0
- package/packages/gantt/src/views/day.ts +74 -0
- package/packages/gantt/src/views/factory.ts +25 -0
- package/packages/gantt/src/views/month.ts +66 -0
- package/packages/gantt/src/views/quarter.ts +68 -0
- package/packages/gantt/src/views/test/day.spec.ts +45 -0
- package/packages/gantt/src/views/test/factory.spec.ts +41 -0
- package/packages/gantt/src/views/test/mock.ts +14 -0
- package/packages/gantt/src/views/test/month.spec.ts +45 -0
- package/packages/gantt/src/views/test/quarter.spec.ts +45 -0
- package/packages/gantt/src/views/test/view.spec.ts +144 -0
- package/packages/gantt/src/views/test/week.spec.ts +45 -0
- package/packages/gantt/src/views/test/year.spec.ts +45 -0
- package/packages/gantt/src/views/view.ts +186 -0
- package/packages/gantt/src/views/week.ts +66 -0
- package/packages/gantt/src/views/year.ts +62 -0
- package/packages/gantt/tsconfig.lib.json +20 -0
- package/packages/gantt/tsconfig.lib.prod.json +9 -0
- package/packages/gantt/tsconfig.schematics.json +25 -0
- package/packages/gantt/tsconfig.spec.json +17 -0
- package/packages/gantt/tslint.json +18 -0
- package/scss-bundle.config.json +7 -0
- package/tsconfig.json +26 -0
- package/tslint.json +51 -0
- package/bundles/worktile-gantt.umd.js +0 -3129
- package/bundles/worktile-gantt.umd.js.map +0 -1
- package/bundles/worktile-gantt.umd.min.js +0 -16
- package/bundles/worktile-gantt.umd.min.js.map +0 -1
- package/class/date-point.d.ts +0 -15
- package/class/group.d.ts +0 -22
- package/class/item.d.ts +0 -70
- package/class/view-type.d.ts +0 -7
- package/components/bar/bar-drag.d.ts +0 -34
- package/components/bar/bar.component.d.ts +0 -23
- package/components/calendar/calendar.component.d.ts +0 -25
- package/components/drag-backdrop/drag-backdrop.component.d.ts +0 -6
- package/components/icon/icon.component.d.ts +0 -10
- package/components/icon/icons.d.ts +0 -8
- package/components/links/links.component.d.ts +0 -44
- package/components/main/gantt-main.component.d.ts +0 -18
- package/components/range/range.component.d.ts +0 -10
- package/components/table/gantt-table.component.d.ts +0 -31
- package/esm2015/class/date-point.js +0 -10
- package/esm2015/class/event.js +0 -13
- package/esm2015/class/group.js +0 -17
- package/esm2015/class/index.js +0 -6
- package/esm2015/class/item.js +0 -78
- package/esm2015/class/view-type.js +0 -9
- package/esm2015/components/bar/bar-drag.js +0 -266
- package/esm2015/components/bar/bar.component.js +0 -91
- package/esm2015/components/calendar/calendar.component.js +0 -82
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +0 -18
- package/esm2015/components/icon/icon.component.js +0 -36
- package/esm2015/components/icon/icons.js +0 -87
- package/esm2015/components/links/links.component.js +0 -207
- package/esm2015/components/main/gantt-main.component.js +0 -35
- package/esm2015/components/range/range.component.js +0 -32
- package/esm2015/components/table/gantt-table.component.js +0 -128
- package/esm2015/gantt-dom.service.js +0 -101
- package/esm2015/gantt-drag-container.js +0 -57
- package/esm2015/gantt-item-upper.js +0 -55
- package/esm2015/gantt-print.service.js +0 -92
- package/esm2015/gantt-upper.js +0 -231
- package/esm2015/gantt.component.js +0 -105
- package/esm2015/gantt.module.js +0 -43
- package/esm2015/gantt.pipe.js +0 -33
- package/esm2015/gantt.styles.js +0 -15
- package/esm2015/public-api.js +0 -16
- package/esm2015/root.component.js +0 -111
- package/esm2015/table/gantt-column.component.js +0 -28
- package/esm2015/table/gantt-table.component.js +0 -18
- package/esm2015/utils/date.js +0 -160
- package/esm2015/utils/helpers.js +0 -45
- package/esm2015/views/day.js +0 -54
- package/esm2015/views/factory.js +0 -23
- package/esm2015/views/month.js +0 -48
- package/esm2015/views/quarter.js +0 -51
- package/esm2015/views/view.js +0 -121
- package/esm2015/views/week.js +0 -49
- package/esm2015/views/year.js +0 -50
- package/esm2015/worktile-gantt.js +0 -16
- package/fesm2015/worktile-gantt.js +0 -2491
- package/fesm2015/worktile-gantt.js.map +0 -1
- package/gantt-dom.service.d.ts +0 -29
- package/gantt-drag-container.d.ts +0 -20
- package/gantt-item-upper.d.ts +0 -17
- package/gantt-print.service.d.ts +0 -10
- package/gantt-upper.d.ts +0 -62
- package/gantt.component.d.ts +0 -28
- package/gantt.module.d.ts +0 -2
- package/gantt.pipe.d.ts +0 -11
- package/gantt.styles.d.ts +0 -15
- package/root.component.d.ts +0 -25
- package/style.scss +0 -645
- package/table/gantt-column.component.d.ts +0 -12
- package/table/gantt-table.component.d.ts +0 -7
- package/utils/date.d.ts +0 -59
- package/utils/helpers.d.ts +0 -11
- package/views/day.d.ts +0 -14
- package/views/factory.d.ts +0 -8
- package/views/month.d.ts +0 -12
- package/views/quarter.d.ts +0 -12
- package/views/view.d.ts +0 -56
- package/views/week.d.ts +0 -12
- package/views/year.d.ts +0 -12
- package/worktile-gantt.d.ts +0 -15
- package/worktile-gantt.metadata.json +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<div class="gantt-table-header gantt-table-row">
|
|
2
|
+
<div class="gantt-table-column" *ngFor="let column of columnList; let i = index" [style.width]="column.columnWidth">
|
|
3
|
+
<ng-container *ngIf="column.headerTemplateRef; else default" [ngTemplateOutlet]="column.headerTemplateRef"></ng-container>
|
|
4
|
+
<ng-template #default>
|
|
5
|
+
{{ column.name }}
|
|
6
|
+
</ng-template>
|
|
7
|
+
<div
|
|
8
|
+
class="gantt-table-drag-trigger"
|
|
9
|
+
cdkDrag
|
|
10
|
+
cdkDragLockAxis="x"
|
|
11
|
+
cdkDragBoundary=".gantt"
|
|
12
|
+
(cdkDragMoved)="dragMoved($event, column)"
|
|
13
|
+
(cdkDragStarted)="dragStarted($event)"
|
|
14
|
+
(cdkDragEnded)="columnDragEnded($event, column)"
|
|
15
|
+
></div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="gantt-table-body">
|
|
19
|
+
<ng-container *ngIf="!groups.length && !items.length">
|
|
20
|
+
<ng-container *ngIf="!emptyTemplate">
|
|
21
|
+
<gantt-icon class="empty-icon" iconName="empty"></gantt-icon>
|
|
22
|
+
<div class="empty-text">没有数据</div>
|
|
23
|
+
</ng-container>
|
|
24
|
+
<ng-template [ngTemplateOutlet]="emptyTemplate"></ng-template>
|
|
25
|
+
</ng-container>
|
|
26
|
+
|
|
27
|
+
<ng-container *ngIf="groups && groups.length > 0; else itemsTemplate">
|
|
28
|
+
<ng-container *ngFor="let group of groups">
|
|
29
|
+
<div class="gantt-table-group" [ngClass]="group.class">
|
|
30
|
+
<div class="gantt-table-group-title" [class.expanded]="group.expanded" (click)="expandGroup(group)">
|
|
31
|
+
<gantt-icon class="expand-icon" [iconName]="group.expanded ? 'angle-down' : 'angle-right'"></gantt-icon>
|
|
32
|
+
<ng-container *ngIf="groupTemplate; else default">
|
|
33
|
+
<ng-template
|
|
34
|
+
[ngTemplateOutlet]="groupTemplate"
|
|
35
|
+
[ngTemplateOutletContext]="{ $implicit: group.origin, group: group.origin }"
|
|
36
|
+
></ng-template>
|
|
37
|
+
</ng-container>
|
|
38
|
+
<ng-template #default>
|
|
39
|
+
<span class="group-title">{{ group.title }}</span>
|
|
40
|
+
</ng-template>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<ng-container *ngIf="group.expanded">
|
|
45
|
+
<ng-template
|
|
46
|
+
[ngTemplateOutlet]="ganttItems"
|
|
47
|
+
[ngTemplateOutletContext]="{ group: group, items: group.items, level: 0 }"
|
|
48
|
+
></ng-template>
|
|
49
|
+
</ng-container>
|
|
50
|
+
</ng-container>
|
|
51
|
+
</ng-container>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
class="gantt-table-drag-trigger"
|
|
56
|
+
cdkDrag
|
|
57
|
+
cdkDragLockAxis="x"
|
|
58
|
+
cdkDragBoundary=".gantt"
|
|
59
|
+
(cdkDragMoved)="dragMoved($event)"
|
|
60
|
+
(cdkDragStarted)="dragStarted($event)"
|
|
61
|
+
(cdkDragEnded)="tableDragEnded($event)"
|
|
62
|
+
></div>
|
|
63
|
+
|
|
64
|
+
<div #dragLine class="gantt-table-drag-auxiliary-line"></div>
|
|
65
|
+
|
|
66
|
+
<ng-template #itemsTemplate>
|
|
67
|
+
<ng-template [ngTemplateOutlet]="ganttItems" [ngTemplateOutletContext]="{ items: items, level: 0 }"></ng-template>
|
|
68
|
+
</ng-template>
|
|
69
|
+
|
|
70
|
+
<ng-template #ganttItems let-group="group" let-items="items" let-level="level">
|
|
71
|
+
<ng-container *ngFor="let item of items">
|
|
72
|
+
<div
|
|
73
|
+
class="gantt-table-item gantt-table-row"
|
|
74
|
+
[class.gantt-table-item-first-level-group]="level === 0 && (item.type | isGanttRangeItem)"
|
|
75
|
+
[class.gantt-table-item-with-group]="group"
|
|
76
|
+
[style.height.px]="gantt.styles.lineHeight"
|
|
77
|
+
[style.lineHeight.px]="gantt.styles.lineHeight"
|
|
78
|
+
>
|
|
79
|
+
<div class="gantt-table-column" *ngFor="let column of columnList; let first = first" [style.width]="column.columnWidth">
|
|
80
|
+
<div *ngIf="first" class="gantt-expand-icon" [style.marginLeft.px]="level * 20">
|
|
81
|
+
<ng-container *ngIf="level < gantt.maxLevel - 1 && item.expandable">
|
|
82
|
+
<gantt-icon
|
|
83
|
+
*ngIf="!item.loading"
|
|
84
|
+
class="expand-icon"
|
|
85
|
+
[iconName]="item.expanded ? 'angle-down' : 'angle-right'"
|
|
86
|
+
(click)="expandChildren(item)"
|
|
87
|
+
></gantt-icon>
|
|
88
|
+
<gantt-icon *ngIf="item.loading" [iconName]="'loading'"></gantt-icon>
|
|
89
|
+
</ng-container>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="gantt-table-column-content">
|
|
92
|
+
<ng-template
|
|
93
|
+
[ngTemplateOutlet]="column.templateRef"
|
|
94
|
+
[ngTemplateOutletContext]="{ $implicit: item.origin, item: item.origin }"
|
|
95
|
+
></ng-template>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<ng-template
|
|
100
|
+
*ngIf="item.children && item.expanded"
|
|
101
|
+
[ngTemplateOutlet]="ganttItems"
|
|
102
|
+
[ngTemplateOutletContext]="{ items: item.children, level: level + 1, group: group }"
|
|
103
|
+
></ng-template>
|
|
104
|
+
</ng-container>
|
|
105
|
+
</ng-template>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
.gantt-table {
|
|
2
|
+
display: block;
|
|
3
|
+
&-empty {
|
|
4
|
+
height: 100%;
|
|
5
|
+
position: relative;
|
|
6
|
+
.gantt-table-body {
|
|
7
|
+
position: absolute;
|
|
8
|
+
text-align: center;
|
|
9
|
+
top: 50%;
|
|
10
|
+
left: 50%;
|
|
11
|
+
transform: translate(-50%, -50%);
|
|
12
|
+
margin-top: 22px;
|
|
13
|
+
.empty-icon {
|
|
14
|
+
svg {
|
|
15
|
+
height: 78px;
|
|
16
|
+
width: 78px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
.empty-text {
|
|
20
|
+
color: #cacaca;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-drag-trigger {
|
|
26
|
+
width: $gantt-table-header-drag-line-width;
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
bottom: 0;
|
|
31
|
+
cursor: ew-resize;
|
|
32
|
+
z-index: 1;
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
background: $gantt-table-header-drag-line-color;
|
|
36
|
+
z-index: 2;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-drag-auxiliary-line {
|
|
41
|
+
width: $gantt-table-header-drag-line-width;
|
|
42
|
+
background: $gantt-table-header-drag-line-color;
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 0;
|
|
45
|
+
bottom: 0;
|
|
46
|
+
z-index: 100;
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.gantt-table-row {
|
|
51
|
+
display: flex;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
border-bottom: 1px solid $gantt-border-color;
|
|
54
|
+
|
|
55
|
+
.gantt-table-column {
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
border-right: 1px solid $gantt-border-color;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
position: relative;
|
|
60
|
+
|
|
61
|
+
&:last-child {
|
|
62
|
+
border-right: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.gantt-table-header {
|
|
68
|
+
text-align: center;
|
|
69
|
+
position: sticky;
|
|
70
|
+
top: 0;
|
|
71
|
+
background: #fff;
|
|
72
|
+
z-index: 2;
|
|
73
|
+
height: $gantt-header-height;
|
|
74
|
+
line-height: $gantt-header-height;
|
|
75
|
+
|
|
76
|
+
.gantt-table-column {
|
|
77
|
+
font-weight: 400;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.gantt-table-body {
|
|
82
|
+
.gantt-table-group {
|
|
83
|
+
display: flex;
|
|
84
|
+
height: $gantt-group-height;
|
|
85
|
+
background: $gantt-group-background-color;
|
|
86
|
+
padding: 0 10px;
|
|
87
|
+
align-items: center;
|
|
88
|
+
border-bottom: 1px solid $gantt-border-color;
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
position: relative;
|
|
91
|
+
|
|
92
|
+
.gantt-table-group-title {
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
|
|
95
|
+
.expand-icon {
|
|
96
|
+
color: #aaa;
|
|
97
|
+
margin-right: 6px;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.gantt-table-item {
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
&-first-level-group {
|
|
105
|
+
background: $gantt-group-background-color;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&-with-group {
|
|
109
|
+
.gantt-table-column {
|
|
110
|
+
&:first-child {
|
|
111
|
+
padding: 0 15px 0 32px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.gantt-table-column {
|
|
117
|
+
display: flex;
|
|
118
|
+
padding: $gantt-table-td-padding;
|
|
119
|
+
|
|
120
|
+
&:last-child {
|
|
121
|
+
border-right: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.gantt-table-column-content {
|
|
126
|
+
flex: 1;
|
|
127
|
+
position: relative;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
text-overflow: ellipsis;
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&:hover {
|
|
134
|
+
background-color: $gantt-container-background-color;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.gantt-expand-icon {
|
|
139
|
+
display: inline-block;
|
|
140
|
+
width: 20px;
|
|
141
|
+
color: #aaa;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
HostBinding,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
QueryList,
|
|
6
|
+
Input,
|
|
7
|
+
OnInit,
|
|
8
|
+
ViewChild,
|
|
9
|
+
ElementRef,
|
|
10
|
+
OnChanges,
|
|
11
|
+
SimpleChanges,
|
|
12
|
+
Inject
|
|
13
|
+
} from '@angular/core';
|
|
14
|
+
import { GanttItemInternal, GanttGroupInternal } from '../../class';
|
|
15
|
+
import { NgxGanttTableColumnComponent } from '../../table/gantt-column.component';
|
|
16
|
+
// import { defaultColumnWidth, minColumnWidth } from '../../gantt.component';
|
|
17
|
+
import { CdkDragEnd, CdkDragMove, CdkDragStart } from '@angular/cdk/drag-drop';
|
|
18
|
+
import { coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
19
|
+
import { GanttAbstractComponent, GANTT_ABSTRACT_TOKEN } from '../../gantt-abstract';
|
|
20
|
+
|
|
21
|
+
export const defaultColumnWidth = 100;
|
|
22
|
+
export const minColumnWidth = 80;
|
|
23
|
+
|
|
24
|
+
interface DragFixedConfig {
|
|
25
|
+
target: HTMLElement;
|
|
26
|
+
originWidth: number;
|
|
27
|
+
movedWidth: number;
|
|
28
|
+
minWidth: number;
|
|
29
|
+
}
|
|
30
|
+
@Component({
|
|
31
|
+
selector: 'gantt-table',
|
|
32
|
+
templateUrl: './gantt-table.component.html'
|
|
33
|
+
})
|
|
34
|
+
export class GanttTableComponent implements OnInit, OnChanges {
|
|
35
|
+
public columnList: QueryList<NgxGanttTableColumnComponent>;
|
|
36
|
+
|
|
37
|
+
public dragStartLeft: number;
|
|
38
|
+
|
|
39
|
+
@Input() groups: GanttGroupInternal[];
|
|
40
|
+
|
|
41
|
+
@Input() items: GanttItemInternal[];
|
|
42
|
+
|
|
43
|
+
@Input()
|
|
44
|
+
set columns(columns: QueryList<NgxGanttTableColumnComponent>) {
|
|
45
|
+
columns.forEach((column) => {
|
|
46
|
+
if (!column.columnWidth) {
|
|
47
|
+
column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
this.columnList = columns;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Input() groupTemplate: TemplateRef<any>;
|
|
54
|
+
|
|
55
|
+
@Input() emptyTemplate: TemplateRef<any>;
|
|
56
|
+
|
|
57
|
+
@ViewChild('dragLine', { static: true }) draglineElementRef: ElementRef<HTMLElement>;
|
|
58
|
+
|
|
59
|
+
@HostBinding('class.gantt-table') ganttTableClass = true;
|
|
60
|
+
|
|
61
|
+
@HostBinding('class.gantt-table-empty') ganttTableEmptyClass = false;
|
|
62
|
+
|
|
63
|
+
constructor(@Inject(GANTT_ABSTRACT_TOKEN) public gantt: GanttAbstractComponent, private elementRef: ElementRef) {}
|
|
64
|
+
|
|
65
|
+
ngOnInit() {}
|
|
66
|
+
|
|
67
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
68
|
+
if (!changes.groups.currentValue?.length && !changes.items.currentValue?.length) {
|
|
69
|
+
this.ganttTableEmptyClass = true;
|
|
70
|
+
} else {
|
|
71
|
+
this.ganttTableEmptyClass = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private dragFixed(config: DragFixedConfig) {
|
|
76
|
+
if (config.movedWidth < config.minWidth) {
|
|
77
|
+
config.target.style.transform = `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
expandGroup(group: GanttGroupInternal) {
|
|
82
|
+
this.gantt.expandGroup(group);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
expandChildren(item: GanttItemInternal) {
|
|
86
|
+
this.gantt.expandChildren(item);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dragStarted(event: CdkDragStart) {
|
|
90
|
+
const target = event.source.element.nativeElement;
|
|
91
|
+
this.dragStartLeft = target.getBoundingClientRect().left;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dragMoved(event: CdkDragMove, column?: NgxGanttTableColumnComponent) {
|
|
95
|
+
const target = event.source.element.nativeElement;
|
|
96
|
+
const left = target.getBoundingClientRect().left;
|
|
97
|
+
|
|
98
|
+
let originWidth: number;
|
|
99
|
+
let movedWidth: number;
|
|
100
|
+
let minWidth: number;
|
|
101
|
+
if (column) {
|
|
102
|
+
originWidth = parseInt(column.columnWidth, 10);
|
|
103
|
+
movedWidth = originWidth + (left - this.dragStartLeft);
|
|
104
|
+
minWidth = minColumnWidth;
|
|
105
|
+
} else {
|
|
106
|
+
originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
|
|
107
|
+
movedWidth = originWidth + (left - this.dragStartLeft);
|
|
108
|
+
minWidth = minColumnWidth * this.columnList.length;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.dragFixed({
|
|
112
|
+
target,
|
|
113
|
+
originWidth,
|
|
114
|
+
movedWidth,
|
|
115
|
+
minWidth
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.showAuxiliaryLine(event);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
columnDragEnded(event: CdkDragEnd, column: NgxGanttTableColumnComponent) {
|
|
122
|
+
const target = event.source.element.nativeElement;
|
|
123
|
+
const left = target.getBoundingClientRect().left;
|
|
124
|
+
const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
|
|
125
|
+
const columnWidth = Math.max(width || 0, minColumnWidth);
|
|
126
|
+
column.columnWidth = coerceCssPixelValue(columnWidth);
|
|
127
|
+
if (this.gantt.table) {
|
|
128
|
+
this.gantt.table.columnChanges.emit({ columns: this.columnList });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.hideAuxiliaryLine();
|
|
132
|
+
event.source.reset();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
tableDragEnded(event: CdkDragEnd) {
|
|
136
|
+
const target = event.source.element.nativeElement;
|
|
137
|
+
const left = target.getBoundingClientRect().left;
|
|
138
|
+
const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
|
|
139
|
+
const dragWidth = left - this.dragStartLeft;
|
|
140
|
+
this.columnList.forEach((column) => {
|
|
141
|
+
const lastColumnWidth = parseInt(column.columnWidth, 10);
|
|
142
|
+
const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
|
|
143
|
+
const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
|
|
144
|
+
column.columnWidth = coerceCssPixelValue(columnWidth);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (this.gantt.table) {
|
|
148
|
+
this.gantt.table.columnChanges.emit({ columns: this.columnList });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.hideAuxiliaryLine();
|
|
152
|
+
event.source.reset();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private showAuxiliaryLine(event: CdkDragMove) {
|
|
156
|
+
const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
157
|
+
const targetRect = event.source.element.nativeElement.getBoundingClientRect();
|
|
158
|
+
const distance = { x: targetRect.left - tableRect.left, y: targetRect.top - tableRect.top };
|
|
159
|
+
this.draglineElementRef.nativeElement.style.left = `${distance.x}px`;
|
|
160
|
+
this.draglineElementRef.nativeElement.style.display = 'block';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private hideAuxiliaryLine() {
|
|
164
|
+
this.draglineElementRef.nativeElement.style.display = 'none';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { fakeAsync, TestBed, ComponentFixture, async, inject, flush } from '@angular/core/testing';
|
|
2
|
+
import { Component, ViewChild, DebugElement } from '@angular/core';
|
|
3
|
+
import { NgxGanttModule } from 'ngx-gantt';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
5
|
+
import { GanttTableComponent } from '../gantt-table.component';
|
|
6
|
+
import { getMockGroupItems, getMockGroups} from '../../../test/mocks/data';
|
|
7
|
+
import { dispatchMouseEvent } from '../../../utils/testing';
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'test-gantt-table',
|
|
10
|
+
template: `
|
|
11
|
+
<ngx-gantt #gantt [items]="items" [groups]="groups">
|
|
12
|
+
<ngx-gantt-table>
|
|
13
|
+
<ngx-gantt-column [width]="200" name="标题">
|
|
14
|
+
<ng-template #cell let-item="item">
|
|
15
|
+
{{ item.title }}
|
|
16
|
+
</ng-template>
|
|
17
|
+
</ngx-gantt-column>
|
|
18
|
+
</ngx-gantt-table>
|
|
19
|
+
</ngx-gantt>
|
|
20
|
+
`,
|
|
21
|
+
providers: []
|
|
22
|
+
})
|
|
23
|
+
export class TestGanttTableComponent {
|
|
24
|
+
@ViewChild(GanttTableComponent, { static: true }) ganttTableComponent: GanttTableComponent;
|
|
25
|
+
|
|
26
|
+
items = getMockGroupItems();
|
|
27
|
+
|
|
28
|
+
groups = getMockGroups();
|
|
29
|
+
|
|
30
|
+
constructor() {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('GanttTable', () => {
|
|
34
|
+
let component: TestGanttTableComponent;
|
|
35
|
+
let fixture: ComponentFixture<TestGanttTableComponent>;
|
|
36
|
+
|
|
37
|
+
beforeEach(async(() => {
|
|
38
|
+
TestBed.configureTestingModule({
|
|
39
|
+
imports: [NgxGanttModule],
|
|
40
|
+
declarations: [TestGanttTableComponent]
|
|
41
|
+
}).compileComponents();
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
fixture = TestBed.createComponent(TestGanttTableComponent);
|
|
46
|
+
component = fixture.componentInstance;
|
|
47
|
+
fixture.detectChanges();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should create gantt-table', () => {
|
|
51
|
+
expect(component).toBeDefined();
|
|
52
|
+
const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
|
|
53
|
+
expect(ganttTable).toBeTruthy();
|
|
54
|
+
expect(ganttTable.nativeElement).toBeTruthy();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should expand groups', () => {
|
|
58
|
+
const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
|
|
59
|
+
expect(ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.classList.contains('expanded')).toBeTruthy();
|
|
60
|
+
ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.click();
|
|
61
|
+
fixture.detectChanges();
|
|
62
|
+
expect(ganttTable.query(By.css('.gantt-table-group-title')).nativeNode.classList.contains('expanded')).toBeFalsy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should expand children', () => {
|
|
66
|
+
const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
|
|
67
|
+
const tableChildrenLength = ganttTable.query(By.css('.gantt-table-body')).children.length;
|
|
68
|
+
ganttTable.nativeElement.querySelector('.gantt-table-item-with-group .gantt-expand-icon .expand-icon').click();
|
|
69
|
+
fixture.detectChanges();
|
|
70
|
+
expect(ganttTable.query(By.css('.gantt-table-body')).children.length).toEqual(tableChildrenLength + 1);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should column drag', fakeAsync(() => {
|
|
74
|
+
const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
|
|
75
|
+
const dragTrigger = ganttTable.nativeElement.querySelector('.gantt-table-header .gantt-table-column .gantt-table-drag-trigger');
|
|
76
|
+
fixture.detectChanges();
|
|
77
|
+
flush();
|
|
78
|
+
|
|
79
|
+
const dragTriggerRight = dragTrigger.getBoundingClientRect().right;
|
|
80
|
+
|
|
81
|
+
dispatchMouseEvent(dragTrigger, 'mousedown');
|
|
82
|
+
fixture.detectChanges();
|
|
83
|
+
flush();
|
|
84
|
+
|
|
85
|
+
dispatchMouseEvent(document, 'mousemove', 200);
|
|
86
|
+
fixture.detectChanges();
|
|
87
|
+
flush();
|
|
88
|
+
fixture.detectChanges();
|
|
89
|
+
|
|
90
|
+
dispatchMouseEvent(document, 'mousemove', 250);
|
|
91
|
+
fixture.detectChanges();
|
|
92
|
+
flush();
|
|
93
|
+
fixture.detectChanges();
|
|
94
|
+
|
|
95
|
+
dispatchMouseEvent(document, 'mouseup');
|
|
96
|
+
fixture.detectChanges();
|
|
97
|
+
flush();
|
|
98
|
+
|
|
99
|
+
expect(dragTrigger.getBoundingClientRect().right).not.toBe(dragTriggerRight);
|
|
100
|
+
}));
|
|
101
|
+
|
|
102
|
+
it('should table drag', fakeAsync(() => {
|
|
103
|
+
const ganttTable: DebugElement = fixture.debugElement.query(By.directive(GanttTableComponent));
|
|
104
|
+
const dragTrigger = ganttTable.nativeElement.children[2];
|
|
105
|
+
fixture.detectChanges();
|
|
106
|
+
|
|
107
|
+
const dragTriggerRight = dragTrigger.getBoundingClientRect().right;
|
|
108
|
+
|
|
109
|
+
dispatchMouseEvent(dragTrigger, 'mousedown');
|
|
110
|
+
fixture.detectChanges();
|
|
111
|
+
flush();
|
|
112
|
+
|
|
113
|
+
dispatchMouseEvent(document, 'mousemove', 250, 150);
|
|
114
|
+
fixture.detectChanges();
|
|
115
|
+
flush();
|
|
116
|
+
fixture.detectChanges();
|
|
117
|
+
|
|
118
|
+
dispatchMouseEvent(document, 'mousemove', 50, 50);
|
|
119
|
+
fixture.detectChanges();
|
|
120
|
+
flush();
|
|
121
|
+
fixture.detectChanges();
|
|
122
|
+
|
|
123
|
+
dispatchMouseEvent(document, 'mouseup');
|
|
124
|
+
fixture.detectChanges();
|
|
125
|
+
flush();
|
|
126
|
+
|
|
127
|
+
expect(dragTrigger.getBoundingClientRect().left).not.toBe(dragTriggerRight);
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { GanttGroupInternal, GanttItemInternal } from './class';
|
|
3
|
+
import { GanttStyles } from './gantt.styles';
|
|
4
|
+
import { NgxGanttTableComponent } from './table/gantt-table.component';
|
|
5
|
+
|
|
6
|
+
export interface GanttAbstractComponent {
|
|
7
|
+
table: NgxGanttTableComponent;
|
|
8
|
+
styles: GanttStyles;
|
|
9
|
+
maxLevel: number;
|
|
10
|
+
expandGroup(group: GanttGroupInternal): void;
|
|
11
|
+
expandChildren(item: GanttItemInternal): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const GANTT_ABSTRACT_TOKEN = new InjectionToken<GanttAbstractComponent>('gantt-abstract-token');
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Injectable, ElementRef, OnDestroy } from '@angular/core';
|
|
2
|
+
import { fromEvent, Subject, merge } from 'rxjs';
|
|
3
|
+
import { pairwise, map, auditTime, takeUntil, take, startWith } from 'rxjs/operators';
|
|
4
|
+
import { isNumber } from './utils/helpers';
|
|
5
|
+
|
|
6
|
+
const scrollThreshold = 50;
|
|
7
|
+
|
|
8
|
+
export enum ScrollDirection {
|
|
9
|
+
NONE,
|
|
10
|
+
LEFT,
|
|
11
|
+
RIGHT
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ScrollEvent {
|
|
15
|
+
target: Element;
|
|
16
|
+
direction: ScrollDirection;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Injectable()
|
|
20
|
+
export class GanttDomService implements OnDestroy {
|
|
21
|
+
public root: Element;
|
|
22
|
+
|
|
23
|
+
public side: Element;
|
|
24
|
+
|
|
25
|
+
public container: Element;
|
|
26
|
+
|
|
27
|
+
public sideContainer: Element;
|
|
28
|
+
|
|
29
|
+
public mainContainer: Element;
|
|
30
|
+
|
|
31
|
+
public calendarOverlay: Element;
|
|
32
|
+
|
|
33
|
+
public linksOverlay: Element;
|
|
34
|
+
|
|
35
|
+
private unsubscribe$ = new Subject<void>();
|
|
36
|
+
|
|
37
|
+
constructor() {}
|
|
38
|
+
|
|
39
|
+
private monitorScrollChange() {
|
|
40
|
+
merge(fromEvent(this.mainContainer, 'scroll'), fromEvent(this.sideContainer, 'scroll'))
|
|
41
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
42
|
+
.subscribe((event) => {
|
|
43
|
+
this.syncScroll(event);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
fromEvent(this.mainContainer, 'scroll')
|
|
47
|
+
.pipe(startWith(), takeUntil(this.unsubscribe$))
|
|
48
|
+
.subscribe((event) => {
|
|
49
|
+
// if (this.mainContainer.scrollLeft > 0) {
|
|
50
|
+
// this.side.classList.add('gantt-side-has-shadow');
|
|
51
|
+
// } else {
|
|
52
|
+
// this.side.classList.remove('gantt-side-has-shadow');
|
|
53
|
+
// }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private syncScroll(event: Event) {
|
|
58
|
+
const target = event.currentTarget as HTMLElement;
|
|
59
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
60
|
+
|
|
61
|
+
this.sideContainer.scrollTop = target.scrollTop;
|
|
62
|
+
this.mainContainer.scrollTop = target.scrollTop;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private disableBrowserWheelEvent() {
|
|
66
|
+
const container = this.mainContainer as HTMLElement;
|
|
67
|
+
fromEvent(container, 'wheel')
|
|
68
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
69
|
+
.subscribe((event: WheelEvent) => {
|
|
70
|
+
const delta = event.deltaX;
|
|
71
|
+
if (!delta) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (
|
|
75
|
+
(container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
|
|
76
|
+
(container.scrollLeft === 0 && delta < 0)
|
|
77
|
+
) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
initialize(root: ElementRef<HTMLElement>) {
|
|
84
|
+
this.root = root.nativeElement;
|
|
85
|
+
this.side = this.root.getElementsByClassName('gantt-side')[0];
|
|
86
|
+
this.container = this.root.getElementsByClassName('gantt-container')[0];
|
|
87
|
+
this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
|
|
88
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
89
|
+
this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
|
|
90
|
+
this.monitorScrollChange();
|
|
91
|
+
this.disableBrowserWheelEvent();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getViewerScroll() {
|
|
95
|
+
return fromEvent<Event>(this.mainContainer, 'scroll').pipe(
|
|
96
|
+
map(() => this.mainContainer.scrollLeft),
|
|
97
|
+
pairwise(),
|
|
98
|
+
map(([previous, current]) => {
|
|
99
|
+
const event: ScrollEvent = {
|
|
100
|
+
target: this.mainContainer,
|
|
101
|
+
direction: ScrollDirection.NONE
|
|
102
|
+
};
|
|
103
|
+
if (current - previous < 0) {
|
|
104
|
+
if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
|
|
105
|
+
event.direction = ScrollDirection.LEFT;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (current - previous > 0) {
|
|
109
|
+
if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft < scrollThreshold) {
|
|
110
|
+
event.direction = ScrollDirection.RIGHT;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return event;
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getResize() {
|
|
119
|
+
return fromEvent(window, 'resize').pipe(auditTime(150));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
scrollMainContainer(left: number) {
|
|
123
|
+
if (isNumber(left)) {
|
|
124
|
+
const scrollLeft = left - this.mainContainer.clientWidth / 2;
|
|
125
|
+
this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
|
|
126
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ngOnDestroy() {
|
|
131
|
+
this.unsubscribe$.next();
|
|
132
|
+
this.unsubscribe$.complete();
|
|
133
|
+
}
|
|
134
|
+
}
|