~smitop/eigen.fun

b86083486971666209f869a0e71795c55396d096 — Smitty 3 years ago 014c8c4
Only update button class when needed
1 files changed, 8 insertions(+), 15 deletions(-)

M public/script.js
M public/script.js => public/script.js +8 -15
@@ 15,7 15,6 @@ let state = {
    rendering: {
        dirty: true,
        gridDirty: true,
        buttonsDirty: true,
    },
};



@@ 48,19 47,6 @@ function stateUpdated() {
        can.style.cursor = "auto";
    }
    state.rendering.dirty = true;

    ACTIONS.forEach(action => {
        if (action.actionType === "toggle") {
            const btn = document.getElementById("action-" + action.name);
            if (btn) {
                if (state[action.stateBool]) {
                    btn.classList.add("on");
                } else {
                    btn.classList.remove("on");
                }
            }
        }
    });
}

function themeColor(id) {


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