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

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

Issue 2776763002: MD Settings: Fix scroll when navigating from subpage to About and back. (Closed)
Patch Set: Created 3 years, 9 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 /** 61 /**
62 * @param {!settings.Route} newRoute 62 * @param {!settings.Route} newRoute
63 * @param {settings.Route} oldRoute 63 * @param {settings.Route} oldRoute
64 */ 64 */
65 currentRouteChanged: function(newRoute, oldRoute) { 65 currentRouteChanged: function(newRoute, oldRoute) {
66 var oldRouteWasSection = 66 var oldRouteWasSection =
67 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 67 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
68 oldRoute.parent.section != oldRoute.section; 68 oldRoute.parent.section != oldRoute.section;
69 69
70 // Always scroll to the top if navigating from a section to the root route 70 if (this.scroller) {
71 // or when navigating to the About page. 71 // When navigating from a section to the root route, we just need to
72 if (this.scroller && 72 // scroll to the top, and can early exit afterwards.
73 ((oldRouteWasSection && newRoute == settings.Route.BASIC) || 73 if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
74 newRoute == settings.Route.ABOUT)) { 74 this.scroller.scrollTop = 0;
75 this.scroller.scrollTop = 0; 75 return;
76 return; 76 }
77
78 // When navigating to the About page, we need to scroll to the top, and
79 // still do the rest of section management.
80 if (newRoute == settings.Route.ABOUT)
81 this.scroller.scrollTop = 0;
77 } 82 }
78 83
79 // Scroll to the section except for back/forward. Also scroll for any 84 // Scroll to the section except for back/forward. Also scroll for any
80 // in-page back/forward navigations (from a section or the root page). 85 // in-page back/forward navigations (from a section or the root page).
81 var scrollToSection = 86 var scrollToSection =
82 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || 87 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection ||
83 oldRoute == settings.Route.BASIC; 88 oldRoute == settings.Route.BASIC;
84 89
85 if (oldRoute && (oldRoute.isSubpage() || newRoute.isSubpage())) 90 if (oldRoute && (oldRoute.isSubpage() || newRoute.isSubpage()))
86 this.isSubpageAnimating = true; 91 this.isSubpageAnimating = true;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return /** @type {?SettingsSectionElement} */( 345 return /** @type {?SettingsSectionElement} */(
341 this.$$('settings-section[section="' + section + '"]')); 346 this.$$('settings-section[section="' + section + '"]'));
342 }, 347 },
343 }; 348 };
344 349
345 /** @polymerBehavior */ 350 /** @polymerBehavior */
346 var MainPageBehavior = [ 351 var MainPageBehavior = [
347 settings.RouteObserverBehavior, 352 settings.RouteObserverBehavior,
348 MainPageBehaviorImpl, 353 MainPageBehaviorImpl,
349 ]; 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