epic fail (namespace doesn't load fast enough)
This commit is contained in:
parent
73077c7565
commit
554c3a695d
2 changed files with 7 additions and 15 deletions
7
src/alu.d.ts
vendored
7
src/alu.d.ts
vendored
|
|
@ -1,13 +1,6 @@
|
||||||
export declare global {
|
export declare global {
|
||||||
namespace Alu {
|
namespace Alu {
|
||||||
let store: AluStore;
|
let store: AluStore;
|
||||||
// Settings Content Store (orig. window.loadedContentStorage)
|
|
||||||
let settings: {
|
|
||||||
contentStore: {
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
currentPage: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type DefaultKeys = {
|
type DefaultKeys = {
|
||||||
[key: string]: AluKey;
|
[key: string]: AluKey;
|
||||||
|
|
|
||||||
|
|
@ -56,16 +56,16 @@ export function getStaticPaths() {
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
Alu.settings.contentStore = {};
|
window.loadedContentStorage = {};
|
||||||
Alu.settings.currentPage;
|
window.currentlySelectedTab;
|
||||||
function settingsLoad() {
|
function settingsLoad() {
|
||||||
document.addEventListener("astro:before-swap", () => {
|
document.addEventListener("astro:before-swap", () => {
|
||||||
Alu.settings.currentPage = "";
|
window.currentlySelectedTab = "";
|
||||||
});
|
});
|
||||||
Array.from(document.getElementsByClassName("setting-tab")).forEach((tab) => {
|
Array.from(document.getElementsByClassName("setting-tab")).forEach((tab) => {
|
||||||
const contentToLoad = document.getElementById("content-" + tab.id);
|
const contentToLoad = document.getElementById("content-" + tab.id);
|
||||||
if (contentToLoad) {
|
if (contentToLoad) {
|
||||||
Alu.settings.contentStore[tab.id] = contentToLoad.innerHTML;
|
window.loadedContentStorage[tab.id] = contentToLoad.innerHTML;
|
||||||
contentToLoad.remove();
|
contentToLoad.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,14 +75,13 @@ export function getStaticPaths() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadContent(tabID) {
|
function loadContent(tabID) {
|
||||||
let curTabID = Alu.settings.currentPage
|
if (window.currentlySelectedTab == tabID) return;
|
||||||
if (curTabID == tabID) return;
|
else window.currentlySelectedTab = tabID;
|
||||||
else curTabID = tabID;
|
|
||||||
const currentContent = document.getElementById("current-content");
|
const currentContent = document.getElementById("current-content");
|
||||||
if (currentContent) {
|
if (currentContent) {
|
||||||
currentContent.style.opacity = "0";
|
currentContent.style.opacity = "0";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
currentContent.innerHTML = Alu.settings.contentStore[tabID];
|
currentContent.innerHTML = window.loadedContentStorage[tabID];
|
||||||
currentContent.style.opacity = "1";
|
currentContent.style.opacity = "1";
|
||||||
document.dispatchEvent(new CustomEvent("setting-tabLoad", { detail: tabID }));
|
document.dispatchEvent(new CustomEvent("setting-tabLoad", { detail: tabID }));
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue