Skip to content

Commit 11d67b1

Browse files
committed
#132: align sticky table header dinamically to controls
1 parent 0095197 commit 11d67b1

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
@@ -48,6 +48,7 @@ class GitGraphView {
4848
private readonly viewElem: HTMLElement;
4949
private readonly controlsElem: HTMLElement;
5050
private readonly tableElem: HTMLElement;
51+
private tableColHeadersElem: HTMLElement | null;
5152
private readonly footerElem: HTMLElement;
5253
private readonly showRemoteBranchesElem: HTMLInputElement;
5354
private readonly refreshBtnElem: HTMLElement;
@@ -71,6 +72,7 @@ class GitGraphView {
7172

7273
this.controlsElem = document.getElementById('controls')!;
7374
this.tableElem = document.getElementById('commitTable')!;
75+
this.tableColHeadersElem = document.getElementById('tableColHeaders')!;
7476
this.footerElem = document.getElementById('footer')!;
7577
this.scrollShadowElem = <HTMLInputElement>document.getElementById('scrollShadow')!;
7678

@@ -911,6 +913,11 @@ class GitGraphView {
911913
}
912914
}
913915
}
916+
917+
if (this.config.stickyHeader) {
918+
this.tableColHeadersElem = document.getElementById('tableColHeaders');
919+
this.alignTableHeaderToControls();
920+
}
914921
}
915922

916923
private renderUncommittedChanges() {
@@ -1820,6 +1827,22 @@ class GitGraphView {
18201827
this.requestLoadRepoInfoAndCommits(false, true);
18211828
}
18221829

1830+
private alignTableHeaderToControls() {
1831+
if (!this.tableColHeadersElem) {
1832+
return;
1833+
}
1834+
1835+
const controlsHeight = this.controlsElem.offsetHeight;
1836+
const controlsWidth = this.controlsElem.offsetWidth;
1837+
const tableColHeadersHeight = this.tableColHeadersElem.offsetHeight;
1838+
const bottomBorderWidth = 1;
1839+
const shadowYPos = controlsHeight + tableColHeadersHeight + bottomBorderWidth;
1840+
1841+
this.tableColHeadersElem.style.top = `${controlsHeight}px`;
1842+
this.scrollShadowElem.style.top = `${shadowYPos}px`;
1843+
this.scrollShadowElem.style.width = `${controlsWidth}px`;
1844+
}
1845+
18231846

18241847
/* Observers */
18251848

@@ -1832,6 +1855,10 @@ class GitGraphView {
18321855
windowWidth = window.outerWidth;
18331856
windowHeight = window.outerHeight;
18341857
}
1858+
1859+
if (this.config.stickyHeader) {
1860+
this.alignTableHeaderToControls();
1861+
}
18351862
});
18361863
}
18371864

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)