Index: chrome/browser/resources/vr_shell/vr_shell_ui.js |
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui.js b/chrome/browser/resources/vr_shell/vr_shell_ui.js |
index aa5dde64e36ea99a2a5d4660a09b0e331f2e2186..098f5b8ee9a117abfd6173c18376b876cfbaa731 100644 |
--- a/chrome/browser/resources/vr_shell/vr_shell_ui.js |
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js |
@@ -39,6 +39,8 @@ var vrShellUi = (function() { |
/** @const */ this.MENU_MODE_SCREEN_HEIGHT = 0.8; |
/** @const */ this.MENU_MODE_SCREEN_ELEVATION = 0.2; |
/** @const */ this.BACKGROUND_DISTANCE_MULTIPLIER = 1.414; |
+ /** @const */ this.DOM_INTERCEPTOR_SELECTOR = '#content-interceptor'; |
+ /** @const */ this.DOM_INTERCEPTOR_ELEVATION = 0.01; |
this.menuMode = false; |
this.fullscreen = false; |
@@ -61,6 +63,24 @@ var vrShellUi = (function() { |
backPlane.setFill(new api.NoFill()); |
ui.addElement(backPlane); |
+ // Place invisible plane on top of content quad, to intercept the clicks |
+ // while on menu mode. |
+ this.interceptor = new DomUiElement(this.DOM_INTERCEPTOR_SELECTOR); |
+ let update = new api.UiElementUpdate(); |
+ update.setTranslation(0, 0, this.DOM_INTERCEPTOR_ELEVATION); |
+ update.setVisible(false); |
+ update.setParentId(this.elementId); |
+ update.setSize( |
+ this.MENU_MODE_SCREEN_HEIGHT * this.SCREEN_RATIO, |
+ this.MENU_MODE_SCREEN_HEIGHT); |
+ ui.updateElement(this.interceptor.id, update); |
+ let interceptorButton = |
+ document.querySelector(this.DOM_INTERCEPTOR_SELECTOR); |
+ interceptorButton.addEventListener('click', function() { |
+ uiManager.exitMenuMode(); |
+ ui.flush(); |
+ }); |
+ |
this.updateState(); |
} |
@@ -106,6 +126,10 @@ var vrShellUi = (function() { |
distance = this.FULLSCREEN_DISTANCE; |
} |
+ let update = new api.UiElementUpdate(); |
+ update.setVisible(this.menuMode); |
+ ui.updateElement(this.interceptor.id, update); |
+ |
let anim; |
anim = new api.Animation(this.elementId, ANIM_DURATION); |
anim.setTranslation(0, y, -distance); |
@@ -999,6 +1023,13 @@ var vrShellUi = (function() { |
this.controls.setForwardButtonEnabled(this.canGoForward); |
} |
+ exitMenuMode() { |
+ if (this.menuMode) { |
+ this.menuMode = false; |
+ this.updateState(); |
+ } |
+ } |
+ |
updateState() { |
/** @const */ var URL_INDICATOR_VISIBILITY_TIMEOUT_MS = 5000; |