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

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

Issue 2627403003: MD Settings: Scroll to top when navigating to About page. (Closed)
Patch Set: 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 unified diff | Download patch
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 * Responds to route changes by expanding, collapsing, or scrolling to sections 6 * Responds to route changes by expanding, collapsing, or scrolling to sections
7 * on the page. Expanded sections take up the full height of the container. At 7 * on the page. Expanded sections take up the full height of the container. At
8 * most one section should be expanded at any given time. 8 * most one section should be expanded at any given time.
9 * @polymerBehavior MainPageBehavior 9 * @polymerBehavior MainPageBehavior
10 */ 10 */
(...skipping 30 matching lines...) Expand all
41 var oldRouteWasSection = 41 var oldRouteWasSection =
42 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 42 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
43 oldRoute.parent.section != oldRoute.section; 43 oldRoute.parent.section != oldRoute.section;
44 44
45 // Always scroll to the top if navigating from a section to the root route. 45 // Always scroll to the top if navigating from a section to the root route.
46 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { 46 if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
47 this.scroller.scrollTop = 0; 47 this.scroller.scrollTop = 0;
48 return; 48 return;
49 } 49 }
50 50
51 // Always scroll to the top when navigating to the About page.
dschuyler 2017/01/17 23:33:38 I'm not sure about this, but WDYT about combining
tommycli 2017/01/17 23:47:00 Done.
52 if (newRoute == settings.Route.ABOUT && this.scroller) {
53 this.scroller.scrollTop = 0;
54 return;
55 }
56
51 // Scroll to the section except for back/forward. Also scroll for any 57 // Scroll to the section except for back/forward. Also scroll for any
52 // in-page back/forward navigations (from a section or the root page). 58 // in-page back/forward navigations (from a section or the root page).
53 var scrollToSection = 59 var scrollToSection =
54 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || 60 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
55 oldRoute == settings.Route.BASIC; 61 oldRoute == settings.Route.BASIC;
56 62
57 // For previously uncreated pages (including on first load), allow the page 63 // For previously uncreated pages (including on first load), allow the page
58 // to render before scrolling to or expanding the section. 64 // to render before scrolling to or expanding the section.
59 if (!oldRoute || this.scrollHeight == 0) 65 if (!oldRoute || this.scrollHeight == 0)
60 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 66 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return /** @type {?SettingsSectionElement} */( 307 return /** @type {?SettingsSectionElement} */(
302 this.$$('settings-section[section="' + section + '"]')); 308 this.$$('settings-section[section="' + section + '"]'));
303 }, 309 },
304 }; 310 };
305 311
306 /** @polymerBehavior */ 312 /** @polymerBehavior */
307 var MainPageBehavior = [ 313 var MainPageBehavior = [
308 settings.RouteObserverBehavior, 314 settings.RouteObserverBehavior,
309 MainPageBehaviorImpl, 315 MainPageBehaviorImpl,
310 ]; 316 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698