Fix flicker when page loads
This commit is contained in:
parent
8fcff8c645
commit
72f915aaca
2 changed files with 6 additions and 28 deletions
|
|
@ -19,12 +19,6 @@
|
|||
}
|
||||
|
||||
@media only screen {
|
||||
main {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@media (max-width: 1179px) {
|
||||
.sidebar-hidden #sidetoc {
|
||||
display: none;
|
||||
|
|
@ -51,14 +45,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
.content-wrap {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#sidetoc {
|
||||
margin-top: 20px;
|
||||
margin-left: 20px;
|
||||
margin-right: auto;
|
||||
margin-left: calc(100% + 20px);
|
||||
}
|
||||
#pagetoc {
|
||||
position: fixed;
|
||||
|
|
|
|||
|
|
@ -72,28 +72,18 @@ function updatePageToc(elem = undefined) {
|
|||
}
|
||||
|
||||
if (document.getElementById("sidetoc") === null) {
|
||||
// Element doesn't exist yet, let's create it
|
||||
const main = document.querySelector('main');
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = "content-wrap";
|
||||
|
||||
// Move all children into the wrapper
|
||||
while (main.firstChild) {
|
||||
wrapper.appendChild(main.firstChild);
|
||||
}
|
||||
|
||||
// Append the wrapper back to main
|
||||
main.appendChild(wrapper);
|
||||
// The sidetoc element doesn't exist yet, let's create it
|
||||
|
||||
// Create the empty sidetoc and pagetoc elements
|
||||
const sidetoc = document.createElement("div");
|
||||
const pagetoc = document.createElement("div");
|
||||
sidetoc.id = "sidetoc";
|
||||
pagetoc.id = "pagetoc";
|
||||
|
||||
// And append them to the current DOM
|
||||
sidetoc.appendChild(pagetoc);
|
||||
main.appendChild(sidetoc);
|
||||
|
||||
// And append them to the current DOM
|
||||
const main = document.querySelector('main');
|
||||
main.insertBefore(sidetoc, main.firstChild);
|
||||
}
|
||||
|
||||
if (document.getElementsByClassName("header").length <= 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue