diff --git a/src/hub.js b/src/hub.js index 2d56387dd211fdb5bd4c83f12f69be8795edd920..bef3e16d1419a77cd6aa3336ac709499ea341053 100644 --- a/src/hub.js +++ b/src/hub.js @@ -188,6 +188,10 @@ function mountUI(scene, props = {}) { ); } +function requestFullscreen() { + if (screenfull.enabled && !screenfull.isFullscreen) screenfull.request(); +} + const onReady = async () => { const scene = document.querySelector("a-scene"); const hubChannel = new HubChannel(store); @@ -232,6 +236,7 @@ const onReady = async () => { } document.body.removeChild(scene); } + document.body.removeEventListener("touchend", requestFullscreen); }; const enterScene = async (mediaStream, enterInVR, hubId) => { @@ -246,9 +251,7 @@ const onReady = async () => { if (enterInVR) { scene.enterVR(); } else if (AFRAME.utils.device.isMobile()) { - document.body.addEventListener("touchend", () => { - if (screenfull.enabled && !screenfull.isFullscreen) screenfull.request(); - }); + document.body.addEventListener("touchend", requestFullscreen); } AFRAME.registerInputActions(inGameActions, "default");