Skip to content

Commit

Permalink
Fix fullscreen button for IOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 committed Sep 5, 2023
1 parent e21652b commit f692c20
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Common/hooks/useFullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ export default function useFullscreen(): [
document.removeEventListener("fullscreenchange", onFullscreenChange);
}, []);

function openFullscreen(elem: HTMLElement) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (elem.webkitEnterFullscreen) elem.webkitEnterFullscreen(); // Safari
else elem.requestFullscreen();
}

function exitFullscreen(elem: HTMLElement) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (elem.webkitExitFullscreen) elem.webkitExitFullscreen(); // Safari
else document.exitFullscreen();
}

const setFullscreen = (value: boolean, element?: HTMLElement) => {
const fullscreenElement = element ?? document.documentElement;

if (value) fullscreenElement.requestFullscreen();
else document.exitFullscreen();
if (value) openFullscreen(fullscreenElement);
else exitFullscreen(fullscreenElement);
};

return [isFullscreen, setFullscreen];
Expand Down

0 comments on commit f692c20

Please sign in to comment.