Fix flicker when page loads

This commit is contained in:
Urgau 2025-04-21 17:15:33 +02:00
parent 8fcff8c645
commit 72f915aaca
2 changed files with 6 additions and 28 deletions

View file

@ -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;

View file

@ -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) {