~smitop/eigen.fun

6410767fc830b31870b464d5562d56e29f18b97a — Smitty 3 years ago f893969
Properly set toggles on load
1 files changed, 13 insertions(+), 8 deletions(-)

M public/script.js
M public/script.js => public/script.js +13 -8
@@ 416,6 416,17 @@ function curTransitionState() {
    };
}

function updateActionDom(action) {
    const btn = document.getElementById("action-" + action.name);
    if (btn) {
        if (state[action.stateBool]) {
            btn.classList.add("on");
        } else {
            btn.classList.remove("on");
        }
    }
}

function execAction(id, slow) {
    const action = ACTIONS[id];
    if (action.actionType === "move") {


@@ 432,14 443,7 @@ function execAction(id, slow) {
    } else if (action.actionType === "toggle") {
        state[action.stateBool] = !state[action.stateBool];
        state.rendering.gridDirty = true;
        const btn = document.getElementById("action-" + action.name);
        if (btn) {
            if (state[action.stateBool]) {
                btn.classList.add("on");
            } else {
                btn.classList.remove("on");
            }
        }
        updateActionDom(action);
    }
    stateUpdated();
}


@@ 508,6 512,7 @@ document.addEventListener("DOMContentLoaded", () => {
        if (btn) {
            btn.onclick = () => execAction(id, false);
        }
        updateActionDom(action);
    });

    stateUpdated();