Skip to content

Commit 0fd9a78

Browse files
committed
#132: align sticky table header dinamically to controls
1 parent ccffa02 commit 0fd9a78

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

web/main.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class GitGraphView {
4545
private readonly viewElem: HTMLElement;
4646
private readonly controlsElem: HTMLElement;
4747
private readonly tableElem: HTMLElement;
48+
private tableColHeadersElem: HTMLElement | null;
4849
private readonly footerElem: HTMLElement;
4950
private readonly showRemoteBranchesElem: HTMLInputElement;
5051
private readonly refreshBtnElem: HTMLElement;
@@ -66,6 +67,7 @@ class GitGraphView {
6667

6768
this.controlsElem = document.getElementById('controls')!;
6869
this.tableElem = document.getElementById('commitTable')!;
70+
this.tableColHeadersElem = document.getElementById('tableColHeaders')!;
6971
this.footerElem = document.getElementById('footer')!;
7072
this.scrollShadowElem = <HTMLInputElement>document.getElementById('scrollShadow')!;
7173

@@ -839,6 +841,11 @@ class GitGraphView {
839841
}
840842
}
841843
}
844+
845+
if (this.config.stickyHeader) {
846+
this.tableColHeadersElem = document.getElementById('tableColHeaders');
847+
this.alignTableHeaderToControls();
848+
}
842849
}
843850

844851
private renderUncommittedChanges() {
@@ -1746,6 +1753,22 @@ class GitGraphView {
17461753
this.requestLoadRepoInfoAndCommits(false, true);
17471754
}
17481755

1756+
private alignTableHeaderToControls() {
1757+
if (!this.tableColHeadersElem) {
1758+
return;
1759+
}
1760+
1761+
const controlsHeight = this.controlsElem.offsetHeight;
1762+
const controlsWidth = this.controlsElem.offsetWidth;
1763+
const tableColHeadersHeight = this.tableColHeadersElem.offsetHeight;
1764+
const bottomBorderWidth = 1;
1765+
const shadowYPos = controlsHeight + tableColHeadersHeight + bottomBorderWidth;
1766+
1767+
this.tableColHeadersElem.style.top = `${controlsHeight}px`;
1768+
this.scrollShadowElem.style.top = `${shadowYPos}px`;
1769+
this.scrollShadowElem.style.width = `${controlsWidth}px`;
1770+
}
1771+
17491772

17501773
/* Observers */
17511774

@@ -1758,6 +1781,10 @@ class GitGraphView {
17581781
windowWidth = window.outerWidth;
17591782
windowHeight = window.outerHeight;
17601783
}
1784+
1785+
if (this.config.stickyHeader) {
1786+
this.alignTableHeaderToControls();
1787+
}
17611788
});
17621789
}
17631790

web/styles/main.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ body.selection-background-color-exists ::selection{
7070
top:0;
7171
left:0;
7272
right:0;
73-
height:0;
74-
box-shadow:0 -6px 6px 6px var(--vscode-scrollbar-shadow);
73+
height:6px;
74+
box-shadow: inset 0 6px 6px -6px var(--vscode-scrollbar-shadow);
7575
z-index:20;
76+
pointer-events:none;
7677
}
7778

7879
.blockUserInteraction{
@@ -281,7 +282,7 @@ body.selection-background-color-exists ::selection{
281282
}
282283
#tableColHeaders.sticky .tableColHeader {
283284
position: sticky;
284-
top: 41px;
285+
top: inherit;
285286
z-index: 3;
286287
background-color: var(--vscode-editor-background);
287288
}

0 commit comments

Comments
 (0)