Use CSS class to hide elements

This commit is contained in:
Unrud 2019-11-03 14:06:42 +01:00
parent dfa70a56b5
commit b5af659f79
3 changed files with 13 additions and 9 deletions

File diff suppressed because one or more lines are too long

View file

@ -312,7 +312,7 @@ window.addEventListener("load", function() {
function showScene(scene) { function showScene(scene) {
[opening, closed, pad, keys, keyboard].forEach(function (e) { [opening, closed, pad, keys, keyboard].forEach(function (e) {
e.style.display = e == scene ? "flex" : "none"; e.classList.toggle("hidden", e != scene);
}); });
} }
@ -368,7 +368,7 @@ window.addEventListener("load", function() {
document.getElementById("keysbutton").addEventListener("click", showKeys); document.getElementById("keysbutton").addEventListener("click", showKeys);
document.getElementById("keyboardbutton").addEventListener("click", showKeyboard); document.getElementById("keyboardbutton").addEventListener("click", showKeyboard);
if (!fullscreenEnabled()) { if (!fullscreenEnabled()) {
fullscreenbutton.style.display = "none"; fullscreenbutton.classList.add("hidden");
} }
fullscreenbutton.addEventListener("click", function() { fullscreenbutton.addEventListener("click", function() {
if (fullscreenElement()) { if (fullscreenElement()) {
@ -397,9 +397,9 @@ window.addEventListener("load", function() {
window.history.back(); window.history.back();
}); });
window.onpopstate = function() { window.onpopstate = function() {
if (pad.style.display != "none" || if (!pad.classList.contains("hidden") ||
keyboard.style.display != "none" || !keyboard.classList.contains("hidden") ||
keys.style.display != "none") { !keys.classList.contains("hidden")) {
if (history.state == "keys") { if (history.state == "keys") {
showKeys(); showKeys();
} else if (history.state == "keyboard") { } else if (history.state == "keyboard") {

View file

@ -10,6 +10,10 @@
user-select: none; user-select: none;
} }
.hidden {
display: none;
}
html, html,
body, body,
body > div { body > div {