From 37f63afa6948955e6091fcf4f048af3cb636948b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Sat, 12 Nov 2022 03:02:41 +0000 Subject: [PATCH] refactor: conditional native fullscreen --- examples/web/react/components/display/display.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/web/react/components/display/display.tsx b/examples/web/react/components/display/display.tsx index 00a77946..4c44d275 100644 --- a/examples/web/react/components/display/display.tsx +++ b/examples/web/react/components/display/display.tsx @@ -31,6 +31,7 @@ type DisplayProps = { options?: DisplayOptions; size?: string; fullscreen?: boolean; + nativeFullscreen?: boolean; style?: string[]; onDrawHandler?: (caller: DrawHandler) => void; onClearHandler?: (caller: ClearHandler) => void; @@ -50,6 +51,7 @@ export const Display: FC<DisplayProps> = ({ options = { width: 320, height: 288, logicWidth: 160, logicHeight: 144 }, size = "small", fullscreen = false, + nativeFullscreen = true, style = [], onDrawHandler, onClearHandler, @@ -95,7 +97,7 @@ export const Display: FC<DisplayProps> = ({ // requests the browser to go fullscreen using the // body of the document as the entry HTML element - document.body.requestFullscreen(); + nativeFullscreen && document.body?.requestFullscreen(); } else { setWidth(undefined); setHeight(undefined); @@ -106,7 +108,7 @@ export const Display: FC<DisplayProps> = ({ // restores the window mode, returning from the // fullscreen browser - document.exitFullscreen(); + nativeFullscreen && document?.exitFullscreen(); } return () => { window.removeEventListener("resize", resizeRef.current); -- GitLab