feat: fullscreen disabling on old browsers

This commit is contained in:
TrèsAbhi committed 2024-01-16 14:09:19 -06:00
1 parent 7e1949ccc7
commit 512134162d
1 file changed
+15 -12
@@ -19,6 +19,7 @@ export function Options({ isFullScreen, canvas }: OptionsProps) {
const greenPenetration = useTankopedia(
(state) => state.model.visual.greenPenetration,
);
const fullScreenAvailable = document.fullscreenEnabled;
return (
<Flex
@@ -61,18 +62,20 @@ export function Options({ isFullScreen, canvas }: OptionsProps) {
</DropdownMenu.Content>
</DropdownMenu.Root>
<Button
variant="ghost"
onClick={() => {
if (isFullScreen) {
document.exitFullscreen();
} else {
canvas.current?.requestFullscreen();
}
}}
>
{isFullScreen ? <ExitFullScreenIcon /> : <EnterFullScreenIcon />}
</Button>
{fullScreenAvailable && (
<Button
variant="ghost"
onClick={() => {
if (isFullScreen) {
document.exitFullscreen();
} else {
canvas.current?.requestFullscreen();
}
}}
>
{isFullScreen ? <ExitFullScreenIcon /> : <EnterFullScreenIcon />}
</Button>
)}
</Flex>
);
}