Instead of fullscreen api, just hide the other elements.

Anyway it was good practice! But this just works better and can
be initialized on pageload with a url param.
master
voussoir 2022-01-14 22:23:53 -08:00
parent 437c02820b
commit fa9960e2f4
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 39 additions and 45 deletions

View File

@ -23,6 +23,7 @@
html html
{ {
height: 100vh;
box-sizing: border-box; box-sizing: border-box;
} }
@ -30,12 +31,18 @@ html
body body
{ {
min-height: 100%;
background-color: #0e0e0d; background-color: #0e0e0d;
margin: 0; margin: 0;
display: grid; display: grid;
grid-auto-rows: max-content; grid-auto-rows: max-content;
grid-row-gap: 8px; grid-row-gap: 8px;
} }
body.justthesplash
{
grid-auto-rows: initial;
align-items: center;
}
h2 h2
{ {
@ -962,55 +969,38 @@ function cycle_splash()
fade_out(); fade_out();
} }
function fullscreen_on()
{
const elements = Array.from(document.body.children);
for (const element of elements)
{
if (element.id !== "headline")
{
element.classList.add("hidden");
}
}
document.body.classList.add("justthesplash");
}
function fullscreen_off()
{
const elements = Array.from(document.body.children);
for (const element of elements)
{
element.classList.remove("hidden");
}
document.body.classList.remove("justthesplash");
}
function fullscreen_toggle() function fullscreen_toggle()
{ {
const headline = document.getElementById("headline"); if (document.body.classList.contains("justthesplash"))
if (document.fullscreenElement)
{ {
document.exitFullscreen(); fullscreen_off();
fullscreen_showmouse();
} }
else else
{ {
headline.requestFullscreen(); fullscreen_on();
fullscreen_showmouse();
console.log("Let's hide the mouse");
HIDE_MOUSE_TIMEOUT = setTimeout(fullscreen_hidemouse, 2000);
}
}
let HIDE_MOUSE_TIMEOUT = null;
function fullscreen_mousehandler()
{
fullscreen_showmouse();
HIDE_MOUSE_TIMEOUT = setTimeout(fullscreen_hidemouse, 2000);
}
function fullscreen_showmouse()
{
document.getElementById("headline").style.cursor = "";
document.getElementById("headline_fullscreen_button").classList.remove("hidden_opacity");
clearTimeout(HIDE_MOUSE_TIMEOUT);
}
function fullscreen_hidemouse()
{
if (document.fullscreenElement)
{
document.getElementById("headline").style.cursor = "none";
document.getElementById("headline_fullscreen_button").classList.add("hidden_opacity");
}
}
function fullscreenchange_handler()
{
/*
When the user exits fullscreen via F11 or escape, this will catch it.
If they exit by clicking the button it'll be fullscreen_toggle.
*/
const button = document.getElementById("headline_fullscreen_button");
if (! document.fullscreenElement)
{
fullscreen_showmouse();
} }
} }
@ -1019,8 +1009,12 @@ function on_pageload()
shuffle_splashes(); shuffle_splashes();
setTimeout(cycle_splash, 0); setTimeout(cycle_splash, 0);
const headline = document.getElementById("headline"); const headline = document.getElementById("headline");
headline.addEventListener("mousemove", fullscreen_mousehandler);
document.addEventListener("fullscreenchange", fullscreenchange_handler); const url_params = new URLSearchParams(window.location.search);
if (url_params.get("justthesplash") !== null)
{
fullscreen_on();
}
} }
document.addEventListener("DOMContentLoaded", on_pageload); document.addEventListener("DOMContentLoaded", on_pageload);
</script> </script>