Improve netcode and simplify (#4)
- Simplify the logic wherever possible to remove overengineering and simplify the netcode - Actually improve the netcode - The new lines are mainly the package locks and tests Reviewed-on: https://home.schmelczer.dev/git/andras/decla-red/pulls/4
This commit is contained in:
parent
5d854440ec
commit
93a7fe01ab
1 changed files with 15073 additions and 4754 deletions
|
|
@ -18,32 +18,25 @@ export const handleFullScreen = (
|
|||
};
|
||||
|
||||
showButtons();
|
||||
|
||||
let currentWindowHeight = innerHeight;
|
||||
|
||||
const followToggle = () => {
|
||||
SoundHandler.play(Sounds.click);
|
||||
showButtons();
|
||||
currentWindowHeight = innerHeight;
|
||||
};
|
||||
document.addEventListener('fullscreenchange', showButtons);
|
||||
|
||||
const triggerToggle = async () => {
|
||||
await (isInFullScreen()
|
||||
? document.exitFullscreen()
|
||||
: document.body.requestFullscreen());
|
||||
followToggle();
|
||||
try {
|
||||
await (isInFullScreen()
|
||||
? document.exitFullscreen()
|
||||
: document.body.requestFullscreen());
|
||||
SoundHandler.play(Sounds.click);
|
||||
} catch {
|
||||
// The browser may deny fullscreen (for example, when embedded).
|
||||
}
|
||||
};
|
||||
|
||||
addEventListener('keydown', (e) => {
|
||||
if (e.key === 'F11') {
|
||||
triggerToggle();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener('resize', () => {
|
||||
if (isInFullScreen() && currentWindowHeight > innerHeight) {
|
||||
followToggle();
|
||||
if (!e.repeat) {
|
||||
void triggerToggle();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue