Chromium Code Reviews| 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; | |
|
Dan Beam
2016/11/16 02:32:01
do we still want to execute the code that follows
tommycli
2016/11/16 16:39:02
Done. Indeed it does seem that the rest of the cod
| |
| 36 | |
| 33 var scrollToSection = | 37 var scrollToSection = |
| 34 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; | 38 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; |
| 35 | 39 |
| 36 // If this is the first route, or the page was hidden, allow the page to | 40 // If this is the first route, or the page was hidden, allow the page to |
| 37 // render before expanding the section. | 41 // render before expanding the section. |
| 38 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || | 42 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || |
| 39 this.scrollHeight == 0) { | 43 this.scrollHeight == 0) { |
| 40 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); | 44 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| 41 } else { | 45 } else { |
| 42 this.tryTransitionToSection_(scrollToSection); | 46 this.tryTransitionToSection_(scrollToSection); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 return /** @type {?SettingsSectionElement} */( | 272 return /** @type {?SettingsSectionElement} */( |
| 269 this.$$('settings-section[section="' + section + '"]')); | 273 this.$$('settings-section[section="' + section + '"]')); |
| 270 }, | 274 }, |
| 271 }; | 275 }; |
| 272 | 276 |
| 273 /** @polymerBehavior */ | 277 /** @polymerBehavior */ |
| 274 var MainPageBehavior = [ | 278 var MainPageBehavior = [ |
| 275 settings.RouteObserverBehavior, | 279 settings.RouteObserverBehavior, |
| 276 MainPageBehaviorImpl, | 280 MainPageBehaviorImpl, |
| 277 ]; | 281 ]; |
| OLD | NEW |