Skip to content

Commit 72f915a

Browse files
committed
Fix flicker when page loads
1 parent 8fcff8c commit 72f915a

2 files changed

Lines changed: 6 additions & 28 deletions

File tree

‎src/doc/rustc/theme/pagetoc.css‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
}
2020

2121
@mediaonly screen {
22-
main {
23-
display: -webkit-box;
24-
display: -ms-flexbox;
25-
display: flex;
26-
}
27-
2822
@media (max-width:1179px) {
2923
.sidebar-hidden#sidetoc {
3024
display: none;
@@ -51,14 +45,8 @@
5145
}
5246
}
5347

54-
.content-wrap {
55-
width:100%;
56-
}
57-
5848
#sidetoc {
59-
margin-top:20px;
60-
margin-left:20px;
61-
margin-right: auto;
49+
margin-left:calc(100%+20px);
6250
}
6351
#pagetoc {
6452
position: fixed;

‎src/doc/rustc/theme/pagetoc.js‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,18 @@ function updatePageToc(elem = undefined) {
7272
}
7373

7474
if(document.getElementById("sidetoc")===null){
75-
// Element doesn't exist yet, let's create it
76-
constmain=document.querySelector('main');
77-
constwrapper=document.createElement('div');
78-
wrapper.className="content-wrap";
79-
80-
// Move all children into the wrapper
81-
while(main.firstChild){
82-
wrapper.appendChild(main.firstChild);
83-
}
84-
85-
// Append the wrapper back to main
86-
main.appendChild(wrapper);
75+
// The sidetoc element doesn't exist yet, let's create it
8776

8877
// Create the empty sidetoc and pagetoc elements
8978
constsidetoc=document.createElement("div");
9079
constpagetoc=document.createElement("div");
9180
sidetoc.id="sidetoc";
9281
pagetoc.id="pagetoc";
93-
94-
// And append them to the current DOM
9582
sidetoc.appendChild(pagetoc);
96-
main.appendChild(sidetoc);
83+
84+
// And append them to the current DOM
85+
constmain=document.querySelector('main');
86+
main.insertBefore(sidetoc,main.firstChild);
9787
}
9888

9989
if(document.getElementsByClassName("header").length<=1){

0 commit comments

Comments
 (0)