Skip to content

Commit

Permalink
feat: public scrollToToday function
Browse files Browse the repository at this point in the history
  • Loading branch information
luxiaobei committed Jul 1, 2022
1 parent c4a94d6 commit 79b5a6c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions example/src/app/gantt/gantt.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</button>
</thy-button-group>
&nbsp; &nbsp; &nbsp;
<thy-button thyType="primary" thySize="sm" (click)="scrollToToday()">今天</thy-button>
&nbsp; &nbsp; &nbsp;
<thy-button thyType="primary" thySize="sm" (click)="print('gantt-example')"> ↓ 导出为图片 </thy-button>
</ng-template>
<ng-template #headerOperation>
Expand Down
4 changes: 4 additions & 0 deletions example/src/app/gantt/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ export class AppGanttExampleComponent implements OnInit {
print(name: string) {
this.printService.print(name);
}

scrollToToday() {
this.ganttComponent.ganttRoot.scrollToToday();
}
}
2 changes: 1 addition & 1 deletion packages/gantt/src/gantt.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ngx-gantt-root>
<ngx-gantt-root #ganttRoot>
<ng-template #sideTemplate>
<gantt-table
[groups]="groups"
Expand Down
6 changes: 5 additions & 1 deletion packages/gantt/src/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
ContentChild,
TemplateRef,
forwardRef,
Inject
Inject,
ViewChild
} from '@angular/core';
import { startWith, takeUntil, take, finalize } from 'rxjs/operators';
import { Subject, Observable, from } from 'rxjs';
Expand All @@ -27,6 +28,7 @@ import { NgxGanttTableComponent } from './table/gantt-table.component';
import { GANTT_ABSTRACT_TOKEN } from './gantt-abstract';
import { defaultColumnWidth } from './components/table/gantt-table.component';
import { GanttGlobalConfig, GANTT_GLOBAL_CONFIG } from './gantt.config';
import { NgxGanttRootComponent } from './root.component';
@Component({
selector: 'ngx-gantt',
templateUrl: './gantt.component.html',
Expand Down Expand Up @@ -65,6 +67,8 @@ export class NgxGanttComponent extends GanttUpper implements OnInit, AfterViewIn

@ContentChild('tableEmpty', { static: true }) tableEmptyTemplate: TemplateRef<any>;

@ViewChild('ganttRoot') ganttRoot: NgxGanttRootComponent;

private ngUnsubscribe$ = new Subject();

public sideTableWidth = sideWidth;
Expand Down
2 changes: 1 addition & 1 deletion packages/gantt/src/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class NgxGanttRootComponent implements OnInit, OnDestroy {
}
}

private scrollToToday() {
public scrollToToday() {
const x = this.view.getTodayXPoint();
this.dom.scrollMainContainer(x);
}
Expand Down

0 comments on commit 79b5a6c

Please sign in to comment.