mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-12 21:05:19 +02:00
a4f8340b04
Compiles assets/*.ts via sensiolabs/typescript-bundle (standalone SWC binary) and adds Deno for formatting, linting, type-checking, and tests, keeping the project's no-Node/npm approach intact. Wires all four into CI, the Justfile, and the pre-commit hook.
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { Controller } from '@hotwired/stimulus';
|
|
|
|
const STORAGE_KEY = 'tvdt-fullscreen';
|
|
|
|
export default class extends Controller {
|
|
connect(): void {
|
|
document.addEventListener('fullscreenchange', this.onFullscreenChange);
|
|
this.syncState();
|
|
|
|
if (
|
|
sessionStorage.getItem(STORAGE_KEY) === '1' &&
|
|
!document.fullscreenElement
|
|
) {
|
|
this.request();
|
|
}
|
|
}
|
|
|
|
disconnect(): void {
|
|
document.removeEventListener(
|
|
'fullscreenchange',
|
|
this.onFullscreenChange,
|
|
);
|
|
}
|
|
|
|
toggle(): void {
|
|
if (document.fullscreenElement) {
|
|
document.exitFullscreen();
|
|
} else {
|
|
this.request();
|
|
}
|
|
}
|
|
|
|
request(): void {
|
|
document.documentElement.requestFullscreen().catch(() => {});
|
|
}
|
|
|
|
onFullscreenChange = (): void => {
|
|
sessionStorage.setItem(
|
|
STORAGE_KEY,
|
|
document.fullscreenElement ? '1' : '0',
|
|
);
|
|
this.syncState();
|
|
};
|
|
|
|
syncState(): void {
|
|
document.documentElement.classList.toggle(
|
|
'is-fullscreen',
|
|
Boolean(document.fullscreenElement),
|
|
);
|
|
}
|
|
}
|