From 5c750985a6bff3220af7152e31d5b5e2c170680b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 17 Oct 2021 18:41:24 +0200 Subject: [PATCH] Wait 500ms before changing giscus theme on load to make sure that it's ready --- blog/static/js/edition-2/main.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/blog/static/js/edition-2/main.js b/blog/static/js/edition-2/main.js index 1ebee250..f4cb57c2 100644 --- a/blog/static/js/edition-2/main.js +++ b/blog/static/js/edition-2/main.js @@ -1,15 +1,17 @@ window.onload = function () { - let theme = localStorage.getItem("theme"); - if (theme != null) { - set_theme(theme) - } - let container = document.querySelector('#toc-aside'); if (container != null) { resize_toc(container); toc_scroll_position(container); window.onscroll = function () { toc_scroll_position(container) }; } + + let theme = localStorage.getItem("theme"); + if (theme != null) { + setTimeout(() => { + set_giscus_theme(theme) + }, 500); + } } function resize_toc(container) {