Add fullscreenchange event listener
This commit is contained in:
parent
98f4d1c692
commit
9082ca434a
1 changed files with 13 additions and 0 deletions
|
|
@ -110,6 +110,14 @@ function fullscreenElement() {
|
|||
null);
|
||||
}
|
||||
|
||||
function addFullscreenchangeEventListener(listener) {
|
||||
if ("onfullscreenchange" in document) {
|
||||
document.addEventListener("fullscreenchange", listener);
|
||||
} else if ("onwebkitfullscreenchange" in document) {
|
||||
document.addEventListener("webkitfullscreenchange", listener);
|
||||
}
|
||||
}
|
||||
|
||||
function requestPointerLock(element) {
|
||||
if (element.requestPointerLock) {
|
||||
element.requestPointerLock();
|
||||
|
|
@ -498,6 +506,11 @@ window.addEventListener("load", function() {
|
|||
document.getElementById("keyboardbutton").addEventListener("click", function() {
|
||||
showKeyboard();
|
||||
});
|
||||
addFullscreenchangeEventListener(function() {
|
||||
if (fullscreenElement() && !activeScene.classList.contains("fullscreen")) {
|
||||
exitFullscreen();
|
||||
}
|
||||
});
|
||||
if (!fullscreenEnabled()) {
|
||||
fullscreenbutton.classList.add("hidden");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue