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

Side by Side Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2378933004: MD Settings: Skip unseen collapse animation (Closed)
Patch Set: work with about subpage too Created 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_page/settings_section.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * Calls |readyTest| repeatedly until it returns true, then calls 6 * Calls |readyTest| repeatedly until it returns true, then calls
7 * |readyCallback|. 7 * |readyCallback|.
8 * @param {function():boolean} readyTest 8 * @param {function():boolean} readyTest
9 * @param {!Function} readyCallback 9 * @param {!Function} readyCallback
10 */ 10 */
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 /** 204 /**
205 * Animates the card in |section|, collapsing it back into its section. 205 * Animates the card in |section|, collapsing it back into its section.
206 * @param {!SettingsSectionElement} section 206 * @param {!SettingsSectionElement} section
207 * @return {!Promise} Resolved when the transition is finished or canceled. 207 * @return {!Promise} Resolved when the transition is finished or canceled.
208 */ 208 */
209 collapseSection_: function(section) { 209 collapseSection_: function(section) {
210 assert(this.scroller); 210 assert(this.scroller);
211 assert(section.classList.contains('expanded')); 211 assert(section.classList.contains('expanded'));
212 212
213 var canAnimateCollapse = section.canAnimateCollapse(); 213 // Don't animate the collapse if we are transitioning between Basic/Advanced
214 if (canAnimateCollapse) { 214 // and About, since the section won't be visible.
215 var needAnimate =
216 settings.Route.ABOUT.contains(settings.getCurrentRoute()) ==
217 (section.domHost.tagName == 'SETTINGS-ABOUT-PAGE');
218
219 // Animate the collapse if the section knows the original height, except
220 // when switching between Basic/Advanced and About.
221 var shouldAnimateCollapse = needAnimate && section.canAnimateCollapse();
222 if (shouldAnimateCollapse) {
215 this.toggleScrolling_(false); 223 this.toggleScrolling_(false);
216 // Do the initial collapse setup, which takes the section out of the flow, 224 // Do the initial collapse setup, which takes the section out of the flow,
217 // before showing everything. 225 // before showing everything.
218 section.setUpAnimateCollapse(this.scroller); 226 section.setUpAnimateCollapse(this.scroller);
219 } else { 227 } else {
220 section.classList.remove('expanded'); 228 section.classList.remove('expanded');
221 } 229 }
222 230
223 // Show everything. 231 // Show everything.
224 this.toggleOtherSectionsHidden_(section.section, false); 232 this.toggleOtherSectionsHidden_(section.section, false);
225 this.classList.remove('showing-subpage'); 233 this.classList.remove('showing-subpage');
226 234
227 if (!canAnimateCollapse) { 235 if (!shouldAnimateCollapse) {
228 // Finish by restoring the section into the page. 236 // Finish by restoring the section into the page.
229 section.setFrozen(false); 237 section.setFrozen(false);
230 return Promise.resolve(); 238 return Promise.resolve();
231 } 239 }
232 240
233 // Play the actual collapse animation. 241 // Play the actual collapse animation.
234 return new Promise(function(resolve, reject) { 242 return new Promise(function(resolve, reject) {
235 // Wait for the other sections to show up so we can scroll properly. 243 // Wait for the other sections to show up so we can scroll properly.
236 setTimeout(function() { 244 setTimeout(function() {
237 var newSection = settings.getCurrentRoute().section && 245 var newSection = settings.getCurrentRoute().section &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; 309 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)';
302 } 310 }
303 } 311 }
304 }; 312 };
305 313
306 /** @polymerBehavior */ 314 /** @polymerBehavior */
307 var MainPageBehavior = [ 315 var MainPageBehavior = [
308 settings.RouteObserverBehavior, 316 settings.RouteObserverBehavior,
309 MainPageBehaviorImpl, 317 MainPageBehaviorImpl,
310 ]; 318 ];
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_page/settings_section.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698