| 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 12 matching lines...) Expand all Loading... |
| 23 /** | 23 /** |
| 24 * @param {!settings.Route} newRoute | 24 * @param {!settings.Route} newRoute |
| 25 * @param {settings.Route} oldRoute | 25 * @param {settings.Route} oldRoute |
| 26 */ | 26 */ |
| 27 currentRouteChanged: function(newRoute, oldRoute) { | 27 currentRouteChanged: function(newRoute, oldRoute) { |
| 28 // Scroll to the section except for back/forward. Also scroll for any | 28 // Scroll to the section except for back/forward. Also scroll for any |
| 29 // back/forward navigations that are in-page. | 29 // back/forward navigations that are in-page. |
| 30 var oldRouteWasSection = | 30 var oldRouteWasSection = |
| 31 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && | 31 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && |
| 32 oldRoute.parent.section != oldRoute.section; | 32 oldRoute.parent.section != oldRoute.section; |
| 33 |
| 34 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { |
| 35 this.scroller.scrollTop = 0; |
| 36 return; |
| 37 } |
| 38 |
| 33 var scrollToSection = | 39 var scrollToSection = |
| 34 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; | 40 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; |
| 35 | 41 |
| 36 // If this is the first route, or the page was hidden, allow the page to | 42 // If this is the first route, or the page was hidden, allow the page to |
| 37 // render before expanding the section. | 43 // render before expanding the section. |
| 38 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || | 44 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || |
| 39 this.scrollHeight == 0) { | 45 this.scrollHeight == 0) { |
| 40 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); | 46 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| 41 } else { | 47 } else { |
| 42 this.tryTransitionToSection_(scrollToSection); | 48 this.tryTransitionToSection_(scrollToSection); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 return /** @type {?SettingsSectionElement} */( | 274 return /** @type {?SettingsSectionElement} */( |
| 269 this.$$('settings-section[section="' + section + '"]')); | 275 this.$$('settings-section[section="' + section + '"]')); |
| 270 }, | 276 }, |
| 271 }; | 277 }; |
| 272 | 278 |
| 273 /** @polymerBehavior */ | 279 /** @polymerBehavior */ |
| 274 var MainPageBehavior = [ | 280 var MainPageBehavior = [ |
| 275 settings.RouteObserverBehavior, | 281 settings.RouteObserverBehavior, |
| 276 MainPageBehaviorImpl, | 282 MainPageBehaviorImpl, |
| 277 ]; | 283 ]; |
| OLD | NEW |