Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix misalignment when scrollbar scrolls to the edge #389

Merged
merged 5 commits into from
Jul 5, 2023

Conversation

ark-65
Copy link
Contributor

@ark-65 ark-65 commented Jul 3, 2023

No description provided.

@@ -80,6 +91,23 @@ export class NgxGanttRootComponent implements OnInit, OnDestroy {
});
}

ngAfterViewInit() {
setTimeout(() => {
this.updateScrollBarOffset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法的调用放到上面 this.dom.initialize(this.elementRef); 这里下面,这个是有一定是能获取到 mainContainer 的

updateScrollBarOffset() {
if (this.mainTemplate?.elementRef) {
const ganttMainContainer =
this.mainTemplate.elementRef.nativeElement.previousElementSibling.querySelector('.gantt-main').firstChild;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不用这样获取,直接 this.dom.mainContainer 就能获取到,上面的判断也不需要

@@ -235,6 +249,16 @@ export class NgxGanttComponent extends GanttUpper implements OnInit, OnChanges,
this.viewportItems = [...this.viewportItems];
}

private updateScrollBarOffset() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要重新算一遍,直接拿 root 里的就行

@@ -2,7 +2,7 @@
<div class="gantt-header">
<gantt-table-header #tableHeader [columns]="columns"></gantt-table-header>
<div class="gantt-container-header">
<gantt-calendar-header></gantt-calendar-header>
<gantt-calendar-header [style.padding-right.px]="verticalScrollbarWidth"></gantt-calendar-header>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面说了不用再在 gantt 组件里计算滚动条了直接用 [style.padding-right.px]="ganttRoot.verticalScrollbarWidth" 就可以

@HandsomeButterball HandsomeButterball merged commit 6f5c862 into worktile:master Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants