This commit is contained in:
the-djmaze 2022-03-22 11:47:17 +01:00
parent 40a0391092
commit 13f270f426
9 changed files with 75 additions and 90 deletions

View file

@ -11,8 +11,12 @@ export const
elementById = id => doc.getElementById(id),
exitFullscreen = () => getFullscreenElement() && (doc.exitFullscreen || doc.webkitExitFullscreen).call(doc),
getFullscreenElement = () => doc.fullscreenElement || doc.webkitFullscreenElement,
// Fullscreen must be on app, else other popups fail
app = doc.getElementById('rl-app'),
appFullscreen = () => (doc.fullscreenElement || doc.webkitFullscreenElement) === app,
exitFullscreen = () => appFullscreen() && (doc.exitFullscreen || doc.webkitExitFullscreen).call(doc),
isFullscreen = ko.observable(false),
toggleFullscreen = () => isFullscreen() ? exitFullscreen() : app.requestFullscreen(),
Settings = rl.settings,
SettingsGet = Settings.get,
@ -61,6 +65,20 @@ export const
shortcuts.setScope(value);
};
if (app) {
let event = 'fullscreenchange';
if (!app.requestFullscreen && app.webkitRequestFullscreen) {
app.requestFullscreen = app.webkitRequestFullscreen;
event = 'webkit'+event;
}
if (app.requestFullscreen) {
doc.addEventListener(event, () => {
isFullscreen(appFullscreen());
$htmlCL.toggle('rl-fullscreen', appFullscreen());
});
}
}
dropdownVisibility.subscribe(value => {
if (value) {
keyScope(ScopeMenu);