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

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

Issue 2810033002: MD Settings: Always scroll to section when navigating from About section (Closed)
Patch Set: Created 3 years, 8 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 | no next file » | 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 * 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 // When navigating to the About page, we need to scroll to the top, and 75 // When navigating to the About page, we need to scroll to the top, and
76 // still do the rest of section management. 76 // still do the rest of section management.
77 if (newRoute == settings.Route.ABOUT) 77 if (newRoute == settings.Route.ABOUT)
78 this.scroller.scrollTop = 0; 78 this.scroller.scrollTop = 0;
79 } 79 }
80 80
81 // Scroll to the section except for back/forward. Also scroll for any 81 // Scroll to the section except for back/forward. Also scroll for any
82 // in-page back/forward navigations (from a section or the root page). 82 // in-page back/forward navigations (from a section or the root page).
83 var scrollToSection = 83 // Also always scroll when coming from either the About or root page.
84 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || 84 var scrollToSection = !settings.lastRouteChangeWasPopstate() ||
85 oldRoute == settings.Route.BASIC; 85 oldRouteWasSection || oldRoute == settings.Route.BASIC ||
86 oldRoute == settings.Route.ABOUT;
86 87
87 if (oldRoute && (oldRoute.isSubpage() || newRoute.isSubpage())) 88 if (oldRoute && (oldRoute.isSubpage() || newRoute.isSubpage()))
88 this.isSubpageAnimating = true; 89 this.isSubpageAnimating = true;
89 90
90 // For previously uncreated pages (including on first load), allow the page 91 // For previously uncreated pages (including on first load), allow the page
91 // to render before scrolling to or expanding the section. 92 // to render before scrolling to or expanding the section.
92 if (!oldRoute || this.scrollHeight == 0) 93 if (!oldRoute || this.scrollHeight == 0)
93 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 94 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
94 else 95 else
95 this.tryTransitionToSection_(scrollToSection); 96 this.tryTransitionToSection_(scrollToSection);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return /** @type {?SettingsSectionElement} */( 345 return /** @type {?SettingsSectionElement} */(
345 this.$$('settings-section[section="' + section + '"]')); 346 this.$$('settings-section[section="' + section + '"]'));
346 }, 347 },
347 }; 348 };
348 349
349 /** @polymerBehavior */ 350 /** @polymerBehavior */
350 var MainPageBehavior = [ 351 var MainPageBehavior = [
351 settings.RouteObserverBehavior, 352 settings.RouteObserverBehavior,
352 MainPageBehaviorImpl, 353 MainPageBehaviorImpl,
353 ]; 354 ];
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698