Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide UI if in VR in immersive browser #1234

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ document.addEventListener("DOMContentLoaded", async () => {
scene.addEventListener("enter-vr", () => {
if (handleEarlyVRMode()) return true;

if (!isMobileVR) {
// Optimization, stop drawing UI if not visible
remountUI({ hide: true });
}

document.body.classList.add("vr-mode");

// Don't stretch canvas on cardboard, since that's drawing the actual VR view :)
Expand Down Expand Up @@ -624,6 +629,8 @@ document.addEventListener("DOMContentLoaded", async () => {
document.body.classList.remove("vr-mode");
document.body.classList.remove("vr-mode-stretch");

remountUI({ hide: false });

// HACK: Oculus browser pauses videos when exiting VR mode, so we need to resume them after a timeout.
if (/OculusBrowser/i.test(window.navigator.userAgent)) {
document.querySelectorAll("[media-video]").forEach(m => {
Expand Down
5 changes: 4 additions & 1 deletion src/react-components/ui-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class UIRoot extends Component {
location: PropTypes.object,
history: PropTypes.object,
showInterstitialPrompt: PropTypes.bool,
onInterstitialPromptClicked: PropTypes.func
onInterstitialPromptClicked: PropTypes.func,
hide: PropTypes.bool
};

state = {
Expand Down Expand Up @@ -1310,6 +1311,8 @@ class UIRoot extends Component {
};

render() {
if (this.props.hide) return <div />;

const isExited = this.state.exited || this.props.roomUnavailableReason || this.props.platformUnsupportedReason;

const isLoading =
Expand Down