Open jonasfj opened 3 years ago
For anyone looking to work around this issue the following code-snippet should do:
// This ensures that we restore state when user exits fullscreen using escape
if (!window._gdjsFullScreenPatch) {
window._gdjsFullScreenPatch = true;
const game = runtimeScene.getGame();
document.addEventListener('fullscreenchange', () => {
game.getRenderer().setFullScreen(document.fullscreenElement != null);
});
document.addEventListener('webkitfullscreenchange', () => {
game.getRenderer().setFullScreen(document.fullscreenElement != null);
});
document.addEventListener('mozfullscreenchange', () => {
game.getRenderer().setFullScreen(document.fullscreenElement != null);
});
}
Running it once in the beginning of an initial scene should be sufficient.
(this is not something I would suggest as an official patch, just a quick hack to workaround the issue)
gdjs.RuntimeGamePixiRenderer.prototype.isFullScreen
does not detect that users press escape and leave fullscreen mode.This is easy to see from source for
RuntimeGamePixiRenderer
.To Reproduce
Classic application for this is a fullscreen button, which is only visible when not in fullscreen mode![screenshot-button](https://user-images.githubusercontent.com/149732/103378874-1af20680-4ae4-11eb-9bdc-e6b2123fd864.png)
Solution
fullscreenchange
event, which will work after PR #2161webkitfullscreenchange
,mozfullscreenchange
document.fullscreenElement != null
to test if we're fullscreen mode and do:Other details