Skip to content

Commit 2b2adbe

Browse files
committed
TOC: Fix header alignment
1 parent c265768 commit 2b2adbe

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

github-toc.user.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GitHub Table of Contents
3-
// @version 1.3.1
3+
// @version 1.3.2
44
// @description A userscript that adds a table of contents to readme & wiki pages
55
// @license MIT
66
// @author Rob Garrison
@@ -38,8 +38,7 @@
3838
}
3939
.ghus-toc.collapsed > h3 { cursor:pointer; padding-top:5px; border:none; background:#222; color:#ddd; }
4040
.ghus-toc.collapsed .ghus-toc-docs { display:none; }
41-
.ghus-toc.collapsed ~ .Header,
42-
.ghus-toc.collapsed ~ .js-header-wrapper { padding-right: 30px !important; }
41+
.ghus-toc:not(.ghus-toc-hidden).collapsed ~ .js-header-wrapper .Header { padding-right: 48px !important; }
4342
/* move header text out-of-view when collapsed */
4443
.ghus-toc.collapsed > h3 svg { margin-bottom: 10px; }
4544
.ghus-toc-hidden, .ghus-toc.collapsed .boxed-group-inner,
@@ -176,10 +175,10 @@
176175
}
177176
}
178177
// hide TOC entirely, if no rendered markdown detected
179-
function tocView(mode) {
178+
function tocView(isVisible) {
180179
const toc = $(".ghus-toc");
181180
if (toc) {
182-
toc.style.display = mode || "none";
181+
toc.classList.toggle("ghus-toc-hidden", !isVisible);
183182
}
184183
}
185184

@@ -208,7 +207,7 @@
208207
}
209208
}
210209
$(".boxed-group-inner", container).innerHTML = content + "</ul>";
211-
tocView("block");
210+
tocView(true);
212211
listCollapsible();
213212
} else {
214213
tocView();

0 commit comments

Comments
 (0)