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

Unified Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2106013002: Move settings-section animations into setting-section, make better (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Transitions
Patch Set: use strict Created 4 years, 5 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/settings/settings_main/settings_main.js
diff --git a/chrome/browser/resources/settings/settings_main/settings_main.js b/chrome/browser/resources/settings/settings_main/settings_main.js
index f80a8512c0c54b21bc89b73ddfbf8271534494f2..2c5dcacb5615222af84a1e7072eb73a3ee98c69f 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -34,7 +34,12 @@ Polymer({
value: false,
},
- /** @private */
+ /**
+ * True if a section is expanded to show a subpage. Initialized using
+ * currentRoute. Toggles based on expand/collapse events so effects can
+ * be deferred until transitions complete.
+ * @private
+ */
inSubpage_: Boolean,
/**
@@ -89,6 +94,8 @@ Polymer({
function() {
this.resolver_.resolve();
}.bind(this));
+
+ this.inSubpage_ = this.currentRoute.subpage.length > 0;
Dan Beam 2016/07/23 01:13:44 so we don't need to call updatePagesShown_() here?
},
/**
@@ -114,16 +121,36 @@ Polymer({
* @private
*/
currentRouteChanged_: function(newRoute) {
- this.inSubpage_ = newRoute.subpage.length > 0;
- this.style.height = this.inSubpage_ ? '100%' : '';
+ this.updatePagesShown_();
+ },
- if (newRoute.page == 'about') {
- this.showPages_ = {about: true, basic: false, advanced: false};
+ /** @private */
+ subpageExpanded_: function() {
+ this.inSubpage_ = true;
+ // Hide pages other than the current section's parent page.
+ this.updatePagesShown_();
+ },
+
+ /** @private */
+ subpageCollapsing_: function() {
+ this.inSubpage_ = false;
+ // Unhide pages before collapsing the full-height section.
+ this.updatePagesShown_();
+ },
+
+ /**
+ * Updates the hidden state of the about, basic and advanced pages, based on
+ * the current route and the Advanced toggle state.
+ * @private
+ */
+ updatePagesShown_: function() {
+ if (this.currentRoute.page == 'about') {
+ this.showPages_ = {about: true, advanced: false, basic: false};
} else {
this.showPages_ = {
about: false,
- basic: newRoute.page == 'basic' || !this.inSubpage_,
- advanced: newRoute.page == 'advanced' ||
+ basic: this.currentRoute.page == 'basic' || !this.inSubpage_,
+ advanced: this.currentRoute.page == 'advanced' ||
(!this.inSubpage_ && this.advancedToggleExpanded_),
};

Powered by Google App Engine
This is Rietveld 408576698