diff --git a/src/systems/exit-on-blur.js b/src/systems/exit-on-blur.js index f3b3979aa29ae52e924370f7cc1f87a3b20c119d..c6820a4016cbd3440bab91997e19741b006b6b29 100644 --- a/src/systems/exit-on-blur.js +++ b/src/systems/exit-on-blur.js @@ -3,11 +3,14 @@ AFRAME.registerSystem("exit-on-blur", { this.onBlur = this.onBlur.bind(this); this.onFocus = this.onFocus.bind(this); this.onTimeout = this.onTimeout.bind(this); + this.onEnterVR = this.onEnterVR.bind(this); this.isOculusBrowser = navigator.userAgent.match(/Oculus/); + this.enteredVR = false; window.addEventListener("blur", this.onBlur); window.addEventListener("focus", this.onFocus); + this.el.addEventListener("enter-vr", this.onEnterVR); this.exitTimeout = null; }, @@ -17,12 +20,17 @@ AFRAME.registerSystem("exit-on-blur", { // entered standby mode. Currently Oculus Browser is not emitting a blur, vrdisplaydeactivate, // vrdisplayblur, visibilitychange, or vrdisplaypresentchange event, so we wait 15 seconds after // the last requestAnimationFrame callback to determine if the headset has gone into standby mode. - if (this.isOculusBrowser) { + // We also check that you have entered VR so that this timeout does not occur in the setup UI. + if (this.isOculusBrowser && this.enteredVR) { clearTimeout(this.exitTimeout); this.exitTimeout = setTimeout(this.onTimeout, 15 * 1000); } }, + onEnterVR() { + this.enteredVR = true; + }, + onBlur() { if (this.el.isMobile) { clearTimeout(this.exitTimeout);