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

Unified Diff: chrome/browser/resources/settings/settings_page/settings_section.js

Issue 1372713002: Settings Rewrite: Fix subpage animations for direct URLs to subpages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « chrome/browser/resources/settings/settings_page/settings_animated_pages.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/settings_page/settings_section.js
diff --git a/chrome/browser/resources/settings/settings_page/settings_section.js b/chrome/browser/resources/settings/settings_page/settings_section.js
index ee64994ae9b8d3dcee1c1004dda28935b5964b9d..eaa0fb3b0376d7711aec1e5b0a1c7a2e89fb84fc 100644
--- a/chrome/browser/resources/settings/settings_page/settings_section.js
+++ b/chrome/browser/resources/settings/settings_page/settings_section.js
@@ -73,18 +73,36 @@ Polymer({
},
/** @private */
- expanded_: false,
-
- /** @private */
- currentRouteChanged_: function() {
- var expanded = this.currentRoute.section == this.section;
+ currentRouteChanged_: function(newRoute, oldRoute) {
+ var newExpanded = newRoute.section == this.section;
+ var oldExpanded = oldRoute && oldRoute.section == this.section;
+
+ var visible = newExpanded || this.currentRoute.section == '';
+
+ // If the user navigates directly to a subpage, skip all the animations.
+ if (!oldRoute) {
+ if (newExpanded) {
+ // If we navigate directly to a subpage, skip animations.
+ this.classList.add('expanded');
+ this.expandContainer.classList.add('expanded');
+ } else if (!visible) {
+ this.hidden = true;
+ this.$.card.elevation = 0;
+ }
+
+ return;
+ }
- if (expanded != this.expanded_) {
- this.expanded_ = expanded;
- this.playAnimation(expanded ? 'expand' : 'collapse');
+ if (newExpanded && !oldExpanded) {
+ this.playAnimation('expand');
+ } else if (oldExpanded && !newExpanded) {
+ // For contraction, we defer the animation to allow
+ // settings-animated-pages to reflow the new page correctly.
+ this.async(function() {
+ this.playAnimation('collapse');
+ }.bind(this));
}
- var visible = expanded || this.currentRoute.section == '';
this.$.card.elevation = visible ? 1 : 0;
// Remove 'hidden' class immediately, but defer adding it if we are invisble
@@ -97,7 +115,7 @@ Polymer({
onExpandAnimationComplete_: function() {
this.hidden = this.currentRoute.section != '' &&
this.currentRoute.section != this.section;
- }
+ },
});
Polymer({
@@ -158,12 +176,12 @@ Polymer({
section.classList.remove('expanded');
section.expandContainer.classList.remove('expanded');
- // Get the placeholder coordinates before reflowing.
- var newRect = section.$.placeholder.getBoundingClientRect();
+ var card = section.$.card;
+ var newRect = card.getBoundingClientRect();
section.classList.add('neon-animating');
- this._effect = new KeyframeEffect(section.$.card, [
+ this._effect = new KeyframeEffect(card, [
{'top': oldRect.top + 'px', 'height': oldRect.height + 'px'},
{'top': newRect.top + 'px', 'height': newRect.height + 'px'},
], this.timingFromConfig(config));
« no previous file with comments | « chrome/browser/resources/settings/settings_page/settings_animated_pages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698