Skip to content
Snippets Groups Projects
Verified Commit 37f63afa authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

refactor: conditional native fullscreen

parent 3fb8b9ee
No related branches found
No related tags found
No related merge requests found
Pipeline #1519 passed
...@@ -31,6 +31,7 @@ type DisplayProps = { ...@@ -31,6 +31,7 @@ type DisplayProps = {
options?: DisplayOptions; options?: DisplayOptions;
size?: string; size?: string;
fullscreen?: boolean; fullscreen?: boolean;
nativeFullscreen?: boolean;
style?: string[]; style?: string[];
onDrawHandler?: (caller: DrawHandler) => void; onDrawHandler?: (caller: DrawHandler) => void;
onClearHandler?: (caller: ClearHandler) => void; onClearHandler?: (caller: ClearHandler) => void;
...@@ -50,6 +51,7 @@ export const Display: FC<DisplayProps> = ({ ...@@ -50,6 +51,7 @@ export const Display: FC<DisplayProps> = ({
options = { width: 320, height: 288, logicWidth: 160, logicHeight: 144 }, options = { width: 320, height: 288, logicWidth: 160, logicHeight: 144 },
size = "small", size = "small",
fullscreen = false, fullscreen = false,
nativeFullscreen = true,
style = [], style = [],
onDrawHandler, onDrawHandler,
onClearHandler, onClearHandler,
...@@ -95,7 +97,7 @@ export const Display: FC<DisplayProps> = ({ ...@@ -95,7 +97,7 @@ export const Display: FC<DisplayProps> = ({
// requests the browser to go fullscreen using the // requests the browser to go fullscreen using the
// body of the document as the entry HTML element // body of the document as the entry HTML element
document.body.requestFullscreen(); nativeFullscreen && document.body?.requestFullscreen();
} else { } else {
setWidth(undefined); setWidth(undefined);
setHeight(undefined); setHeight(undefined);
...@@ -106,7 +108,7 @@ export const Display: FC<DisplayProps> = ({ ...@@ -106,7 +108,7 @@ export const Display: FC<DisplayProps> = ({
// restores the window mode, returning from the // restores the window mode, returning from the
// fullscreen browser // fullscreen browser
document.exitFullscreen(); nativeFullscreen && document?.exitFullscreen();
} }
return () => { return () => {
window.removeEventListener("resize", resizeRef.current); window.removeEventListener("resize", resizeRef.current);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment