| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * @param {!settings.Route} newRoute | 37 * @param {!settings.Route} newRoute |
| 38 * @param {settings.Route} oldRoute | 38 * @param {settings.Route} oldRoute |
| 39 */ | 39 */ |
| 40 currentRouteChanged: function(newRoute, oldRoute) { | 40 currentRouteChanged: function(newRoute, oldRoute) { |
| 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 // or when navigating to the About page. |
| 47 if (this.scroller && |
| 48 ((oldRouteWasSection && newRoute == settings.Route.BASIC) || |
| 49 newRoute == settings.Route.ABOUT)) { |
| 47 this.scroller.scrollTop = 0; | 50 this.scroller.scrollTop = 0; |
| 48 return; | 51 return; |
| 49 } | 52 } |
| 50 | 53 |
| 51 // Scroll to the section except for back/forward. Also scroll for any | 54 // 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). | 55 // in-page back/forward navigations (from a section or the root page). |
| 53 var scrollToSection = | 56 var scrollToSection = |
| 54 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || | 57 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || |
| 55 oldRoute == settings.Route.BASIC; | 58 oldRoute == settings.Route.BASIC; |
| 56 | 59 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 return /** @type {?SettingsSectionElement} */( | 304 return /** @type {?SettingsSectionElement} */( |
| 302 this.$$('settings-section[section="' + section + '"]')); | 305 this.$$('settings-section[section="' + section + '"]')); |
| 303 }, | 306 }, |
| 304 }; | 307 }; |
| 305 | 308 |
| 306 /** @polymerBehavior */ | 309 /** @polymerBehavior */ |
| 307 var MainPageBehavior = [ | 310 var MainPageBehavior = [ |
| 308 settings.RouteObserverBehavior, | 311 settings.RouteObserverBehavior, |
| 309 MainPageBehaviorImpl, | 312 MainPageBehaviorImpl, |
| 310 ]; | 313 ]; |
| OLD | NEW |