Skip to content

Commit fd68297

Browse files
committed
Revert "refactor: remove exitFullscreen method from global"
`exitFullscreen` was not declared globally but polyfilled under document : https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen
1 parent 9394b9f commit fd68297

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/melonjs/src/system/device.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ export const hasFullscreenSupport =
189189
(prefixed("fullscreenEnabled", globalThis.document) ||
190190
globalThis.document.mozFullScreenEnabled);
191191

192-
let exitFullScreen = hasFullscreenSupport ? document.exitFullscreen() : null;
192+
if (hasFullscreenSupport === true) {
193+
globalThis.document.exitFullscreen =
194+
prefixed("cancelFullScreen", globalThis.document) ||
195+
prefixed("exitFullscreen", globalThis.document);
196+
}
193197

194198
/**
195199
* Device WebAudio Support
@@ -508,7 +512,11 @@ export function requestFullscreen(element) {
508512
* Exit fullscreen mode. Requires fullscreen support from the browser/device.
509513
* @memberof device
510514
*/
511-
export { exitFullScreen };
515+
export function exitFullscreen() {
516+
if (hasFullscreenSupport && isFullscreen()) {
517+
globalThis.document.exitFullscreen();
518+
}
519+
}
512520

513521
/**
514522
* Return a string representing the orientation of the device screen.

0 commit comments

Comments
 (0)