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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 var oldRouteWasSection = | 43 var oldRouteWasSection = |
| 44 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && | 44 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && |
| 45 oldRoute.parent.section != oldRoute.section; | 45 oldRoute.parent.section != oldRoute.section; |
| 46 | 46 |
| 47 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { | 47 if (oldRouteWasSection && newRoute == settings.Route.BASIC) { |
| 48 this.scroller.scrollTop = 0; | 48 this.scroller.scrollTop = 0; |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 | 51 |
| 52 var scrollToSection = | 52 var scrollToSection = |
| 53 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; | 53 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection || |
| 54 oldRoute == settings.Route.BASIC; | |
|
Dan Beam
2016/12/16 00:59:59
can you explain why?
tommycli
2016/12/16 20:17:40
Done. Refactored a bit and expanded comment.
| |
| 54 | 55 |
| 55 // For previously uncreated pages (including on first load), allow the page | 56 // For previously uncreated pages (including on first load), allow the page |
| 56 // to render before scrolling to or expanding the section. | 57 // to render before scrolling to or expanding the section. |
| 57 if (!oldRoute || this.scrollHeight == 0) | 58 if (!oldRoute || this.scrollHeight == 0) |
| 58 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); | 59 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| 59 else | 60 else |
| 60 this.tryTransitionToSection_(scrollToSection); | 61 this.tryTransitionToSection_(scrollToSection); |
| 61 }, | 62 }, |
| 62 | 63 |
| 63 /** | 64 /** |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 return /** @type {?SettingsSectionElement} */( | 299 return /** @type {?SettingsSectionElement} */( |
| 299 this.$$('settings-section[section="' + section + '"]')); | 300 this.$$('settings-section[section="' + section + '"]')); |
| 300 }, | 301 }, |
| 301 }; | 302 }; |
| 302 | 303 |
| 303 /** @polymerBehavior */ | 304 /** @polymerBehavior */ |
| 304 var MainPageBehavior = [ | 305 var MainPageBehavior = [ |
| 305 settings.RouteObserverBehavior, | 306 settings.RouteObserverBehavior, |
| 306 MainPageBehaviorImpl, | 307 MainPageBehaviorImpl, |
| 307 ]; | 308 ]; |
| OLD | NEW |