I am working in react where I have to detect if the web app is in full screen mode or not.
useEffect(() => {
function handleResize() {
setfullScreen(window.innerHeight === window.screen.height)
}
window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize);
}, []);
Above piece of code works well in normal(100%) zoom and detect if the web app is in full screen mode or not.
But when zoomed to 150% it won't detect the full screen mode.
Is there a better way to detect full screen mode in react which works for all zoom level?
use this code:
const zoom = window.devicePixelRatio;
setFullscreen(
window.screen.height === Math.round(window.innerHeight * zoom)
);