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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'cr-settings-section' shows a paper material themed section with a header 7 * 'cr-settings-section' shows a paper material themed section with a header
8 * which shows its page title. 8 * which shows its page title.
9 * 9 *
10 * Example: 10 * Example:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 }; 66 };
67 }, 67 },
68 }, 68 },
69 }, 69 },
70 70
71 listeners: { 71 listeners: {
72 'expand-animation-complete': 'onExpandAnimationComplete_', 72 'expand-animation-complete': 'onExpandAnimationComplete_',
73 }, 73 },
74 74
75 /** @private */ 75 /** @private */
76 expanded_: false, 76 currentRouteChanged_: function(newRoute, oldRoute) {
77 var newExpanded = newRoute.section == this.section;
78 var oldExpanded = oldRoute && oldRoute.section == this.section;
77 79
78 /** @private */ 80 var visible = newExpanded || this.currentRoute.section == '';
79 currentRouteChanged_: function() {
80 var expanded = this.currentRoute.section == this.section;
81 81
82 if (expanded != this.expanded_) { 82 // If the user navigates directly to a subpage, skip all the animations.
83 this.expanded_ = expanded; 83 if (!oldRoute) {
84 this.playAnimation(expanded ? 'expand' : 'collapse'); 84 if (newExpanded) {
85 // If we navigate directly to a subpage, skip animations.
86 this.classList.add('expanded');
87 this.expandContainer.classList.add('expanded');
88 } else if (!visible) {
89 this.hidden = true;
90 this.$.card.elevation = 0;
91 }
92
93 return;
85 } 94 }
86 95
87 var visible = expanded || this.currentRoute.section == ''; 96 if (newExpanded && !oldExpanded) {
97 this.playAnimation('expand');
98 } else if (oldExpanded && !newExpanded) {
99 // For contraction, we defer the animation to allow
100 // settings-animated-pages to reflow the new page correctly.
101 this.async(function() {
102 this.playAnimation('collapse');
103 }.bind(this));
104 }
105
88 this.$.card.elevation = visible ? 1 : 0; 106 this.$.card.elevation = visible ? 1 : 0;
89 107
90 // Remove 'hidden' class immediately, but defer adding it if we are invisble 108 // Remove 'hidden' class immediately, but defer adding it if we are invisble
91 // until the animation is complete. 109 // until the animation is complete.
92 if (visible) 110 if (visible)
93 this.hidden = false; 111 this.hidden = false;
94 }, 112 },
95 113
96 /** @private */ 114 /** @private */
97 onExpandAnimationComplete_: function() { 115 onExpandAnimationComplete_: function() {
98 this.hidden = this.currentRoute.section != '' && 116 this.hidden = this.currentRoute.section != '' &&
99 this.currentRoute.section != this.section; 117 this.currentRoute.section != this.section;
100 } 118 },
101 }); 119 });
102 120
103 Polymer({ 121 Polymer({
104 is: 'expand-card-animation', 122 is: 'expand-card-animation',
105 123
106 behaviors: [ 124 behaviors: [
107 Polymer.NeonAnimationBehavior 125 Polymer.NeonAnimationBehavior
108 ], 126 ],
109 127
110 configure: function(config) { 128 configure: function(config) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 164
147 Polymer({ 165 Polymer({
148 is: 'collapse-card-animation', 166 is: 'collapse-card-animation',
149 167
150 behaviors: [ 168 behaviors: [
151 Polymer.NeonAnimationBehavior 169 Polymer.NeonAnimationBehavior
152 ], 170 ],
153 171
154 configure: function(config) { 172 configure: function(config) {
155 var section = config.node; 173 var section = config.node;
174 var card = section.$.card;
156 var oldRect = section.expandContainer.getBoundingClientRect(); 175 var oldRect = section.expandContainer.getBoundingClientRect();
157 176
158 section.classList.remove('expanded'); 177 section.classList.remove('expanded');
159 section.expandContainer.classList.remove('expanded'); 178 section.expandContainer.classList.remove('expanded');
160 179
161 // Get the placeholder coordinates before reflowing. 180 console.log('collapse placeholder setting');
162 var newRect = section.$.placeholder.getBoundingClientRect(); 181 var newRect = card.getBoundingClientRect();
163 182
164 section.classList.add('neon-animating'); 183 section.classList.add('neon-animating');
165 184
166 this._effect = new KeyframeEffect(section.$.card, [ 185 this._effect = new KeyframeEffect(card, [
167 {'top': oldRect.top + 'px', 'height': oldRect.height + 'px'}, 186 {'top': oldRect.top + 'px', 'height': oldRect.height + 'px'},
168 {'top': newRect.top + 'px', 'height': newRect.height + 'px'}, 187 {'top': newRect.top + 'px', 'height': newRect.height + 'px'},
169 ], this.timingFromConfig(config)); 188 ], this.timingFromConfig(config));
170 return this._effect; 189 return this._effect;
171 }, 190 },
172 191
173 complete: function(config) { 192 complete: function(config) {
174 config.node.classList.remove('neon-animating'); 193 config.node.classList.remove('neon-animating');
175 } 194 }
176 }); 195 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698