immersive-web / cardboard-vr-display

A JavaScript implementation of a WebVR 1.1 VRDisplay
https://immersive-web.github.io/cardboard-vr-display
Apache License 2.0
92 stars 43 forks source link

Hide soft keys when fullscreen #38

Closed WoodNeck closed 4 years ago

WoodNeck commented 4 years ago

Hello, I'd like to suggest a fix for the fullscreen API.

Currently, there's a problem that the soft key is showing up when the requestPresent is called.

KakaoTalk_Photo_2019-11-20-11-02-18

There's a FullscreenOptions that can be used to hide soft keys when presenting in fullscreen mode. Soft key can be hidden by using that like the below.

// src/util.js

Util.requestFullscreen = function(element) {
  if (Util.isWebViewAndroid()) {
      return false;
  }
  if (element.requestFullscreen) {
    element.requestFullscreen({
+      navigationUI: "hide"
    });
  } else if (element.webkitRequestFullscreen) {
    element.webkitRequestFullscreen({
+      navigationUI: "hide"
    });
  } else if (element.mozRequestFullScreen) {
    element.mozRequestFullScreen({
+      navigationUI: "hide"
    });
  } else if (element.msRequestFullscreen) {
    element.msRequestFullscreen({
+      navigationUI: "hide"
    });
  } else {
    return false;
  }

  return true;
};

results in

KakaoTalk_Photo_2019-11-20-11-02-15

I think this either can be a default or can be optioned. Thanks.