Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3291)

Unified Diff: chrome/browser/resources/vr_shell/vr_shell_ui.js

Issue 2624243002: VrShell: Allow native control of UI element opacity. (Closed)
Patch Set: for (auto nit : nits) nit.fix(); Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6f0802e77c8270503550b9df3fb65ba67553c181..872c506870ee1eeef90bcf0953e3d0135deed56f 100644
--- a/chrome/browser/resources/vr_shell/vr_shell_ui.js
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui.js
@@ -315,11 +315,7 @@ var vrShellUi = (function() {
this.backgroundColor = style.backgroundColor;
this.fadeTimeMs = getStyleFloat(style, '--fadeTimeMs');
this.fadeYOffset = getStyleFloat(style, '--fadeYOffset');
-
- // Listen to the end of transitions, so that the box can be natively
- // hidden after it finishes hiding itself.
- document.querySelector('#omnibox')
- .addEventListener('transitionend', this.onAnimationDone.bind(this));
+ this.opacity = getStyleFloat(style, '--opacity');
}
getSecurityIconElementId(level) {
@@ -398,15 +394,10 @@ var vrShellUi = (function() {
this.updateState();
}
- onAnimationDone(e) {
- if (e.propertyName == 'opacity' && this.hidden) {
- this.setNativeVisibility(false);
- }
- }
-
updateState() {
+ this.setNativeVisibility(this.enabled);
+
if (!this.enabled) {
- this.setNativeVisibility(false);
return;
}
@@ -429,22 +420,25 @@ var vrShellUi = (function() {
if (shouldBeHidden != this.hidden) {
// Make the box fade away if it's disappearing.
this.hidden = shouldBeHidden;
- document.querySelector('#omnibox-border').className =
- this.hidden ? 'hidden' : '';
+
+ // Fade-out or fade-in the box.
+ let opacityAnimation =
+ new api.Animation(this.domUiElement.uiElementId, this.fadeTimeMs);
+ opacityAnimation.setOpacity(this.hidden ? 0.0 : this.opacity);
+ ui.addAnimation(opacityAnimation);
// Drop the position as it fades, or raise the position if appearing.
let yOffset = this.hidden ? this.fadeYOffset : 0;
- let animation =
+ let positionAnimation =
new api.Animation(this.domUiElement.uiElementId, this.fadeTimeMs);
- animation.setTranslation(
+ positionAnimation.setTranslation(
this.domUiElement.translationX,
this.domUiElement.translationY + yOffset,
this.domUiElement.translationZ);
- ui.addAnimation(animation);
- ui.flush();
+ ui.addAnimation(positionAnimation);
}
- this.setNativeVisibility(true);
+ ui.flush();
}
setNativeVisibility(visible) {
« no previous file with comments | « chrome/browser/resources/vr_shell/vr_shell_ui.css ('k') | chrome/browser/resources/vr_shell/vr_shell_ui_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698