Optimise
All checks were successful
Check & deploy / build (pull_request) Successful in 1m51s

This commit is contained in:
Andras Schmelczer 2026-05-21 20:33:49 +01:00
parent 6bc125be1c
commit ed5a4379db
76 changed files with 1418 additions and 988 deletions

View file

@ -1,22 +1,24 @@
export class FullScreenHandler {
public constructor(
private readonly minimizeButton: HTMLElement,
private readonly maximizeButton: HTMLElement,
private readonly toggleButton: HTMLElement,
target: HTMLElement
) {
if (!document.fullscreenEnabled || typeof target.requestFullscreen !== 'function') {
minimizeButton.hidden = true;
maximizeButton.hidden = true;
toggleButton.hidden = true;
return;
}
this.updateButtons();
addEventListener('fullscreenchange', this.updateButtons.bind(this));
maximizeButton.addEventListener('click', () => {
toggleButton.addEventListener('click', () => {
if (FullScreenHandler.isInFullScreenMode()) {
void document.exitFullscreen();
return;
}
void target.requestFullscreen().catch(() => undefined);
});
minimizeButton.addEventListener('click', () => document.exitFullscreen());
}
public static isInFullScreenMode(): boolean {
@ -25,7 +27,9 @@ export class FullScreenHandler {
private updateButtons(): void {
const isInFullScreenMode = FullScreenHandler.isInFullScreenMode();
this.minimizeButton.hidden = !isInFullScreenMode;
this.maximizeButton.hidden = isInFullScreenMode;
const label = isInFullScreenMode ? 'Exit fullscreen' : 'Enter fullscreen';
this.toggleButton.classList.toggle('active', isInFullScreenMode);
this.toggleButton.setAttribute('aria-label', label);
this.toggleButton.title = label;
}
}