| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 this.scroller.scrollTop = 0; | 78 this.scroller.scrollTop = 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Scroll to the section except for back/forward. Also scroll for any | 81 // Scroll to the section except for back/forward. Also scroll for any |
| 82 // in-page back/forward navigations (from a section or the root page). | 82 // in-page back/forward navigations (from a section or the root page). |
| 83 // Also always scroll when coming from either the About or root page. | 83 // Also always scroll when coming from either the About or root page. |
| 84 var scrollToSection = !settings.lastRouteChangeWasPopstate() || | 84 var scrollToSection = !settings.lastRouteChangeWasPopstate() || |
| 85 oldRouteWasSection || oldRoute == settings.Route.BASIC || | 85 oldRouteWasSection || oldRoute == settings.Route.BASIC || |
| 86 oldRoute == settings.Route.ABOUT; | 86 oldRoute == settings.Route.ABOUT; |
| 87 | 87 |
| 88 if (oldRoute && (oldRoute.isSubpage() || newRoute.isSubpage())) | 88 // TODO(dschuyler): This doesn't set the flag in the case of going to or |
| 89 // from the main page. It seems sensible to set the flag in those cases, |
| 90 // unfortunately bug 708465 happens. Figure out why that is and then set |
| 91 // this flag more broadly. |
| 92 if (oldRoute && oldRoute.isSubpage() && newRoute.isSubpage()) |
| 89 this.isSubpageAnimating = true; | 93 this.isSubpageAnimating = true; |
| 90 | 94 |
| 91 // For previously uncreated pages (including on first load), allow the page | 95 // For previously uncreated pages (including on first load), allow the page |
| 92 // to render before scrolling to or expanding the section. | 96 // to render before scrolling to or expanding the section. |
| 93 if (!oldRoute || this.scrollHeight == 0) | 97 if (!oldRoute || this.scrollHeight == 0) |
| 94 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); | 98 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| 95 else | 99 else |
| 96 this.tryTransitionToSection_(scrollToSection); | 100 this.tryTransitionToSection_(scrollToSection); |
| 97 }, | 101 }, |
| 98 | 102 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 return /** @type {?SettingsSectionElement} */( | 349 return /** @type {?SettingsSectionElement} */( |
| 346 this.$$('settings-section[section="' + section + '"]')); | 350 this.$$('settings-section[section="' + section + '"]')); |
| 347 }, | 351 }, |
| 348 }; | 352 }; |
| 349 | 353 |
| 350 /** @polymerBehavior */ | 354 /** @polymerBehavior */ |
| 351 var MainPageBehavior = [ | 355 var MainPageBehavior = [ |
| 352 settings.RouteObserverBehavior, | 356 settings.RouteObserverBehavior, |
| 353 MainPageBehaviorImpl, | 357 MainPageBehaviorImpl, |
| 354 ]; | 358 ]; |
| OLD | NEW |