| 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 * Calls |readyTest| repeatedly until it returns true, then calls | 6 * Calls |readyTest| repeatedly until it returns true, then calls |
| 7 * |readyCallback|. | 7 * |readyCallback|. |
| 8 * @param {function():boolean} readyTest | 8 * @param {function():boolean} readyTest |
| 9 * @param {!Function} readyCallback | 9 * @param {!Function} readyCallback |
| 10 */ | 10 */ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 var promise; | 89 var promise; |
| 90 var expandedSection = /** @type {?SettingsSectionElement} */( | 90 var expandedSection = /** @type {?SettingsSectionElement} */( |
| 91 this.$$('settings-section.expanded')); | 91 this.$$('settings-section.expanded')); |
| 92 if (expandedSection) { | 92 if (expandedSection) { |
| 93 // If the section shouldn't be expanded, collapse it. | 93 // If the section shouldn't be expanded, collapse it. |
| 94 if (!currentRoute.isSubpage() || expandedSection != currentSection) { | 94 if (!currentRoute.isSubpage() || expandedSection != currentSection) { |
| 95 promise = this.collapseSection_(expandedSection); | 95 promise = this.collapseSection_(expandedSection); |
| 96 // Scroll to the collapsed section. | 96 // Scroll to the collapsed section. |
| 97 if (currentSection && !settings.lastRouteChangeWasPopstate()) | 97 if (currentSection && !settings.lastRouteChangeWasPopstate()) |
| 98 currentSection.scrollIntoView(); | 98 currentSection.scrollIntoView(); |
| 99 } else { |
| 100 // Scroll to top while sliding to another subpage. |
| 101 this.scroller.scrollTop = 0; |
| 99 } | 102 } |
| 100 } else if (currentSection) { | 103 } else if (currentSection) { |
| 101 // Expand the section into a subpage or scroll to it on the main page. | 104 // Expand the section into a subpage or scroll to it on the main page. |
| 102 if (currentRoute.isSubpage()) | 105 if (currentRoute.isSubpage()) |
| 103 promise = this.expandSection_(currentSection); | 106 promise = this.expandSection_(currentSection); |
| 104 else if (!settings.lastRouteChangeWasPopstate()) | 107 else if (!settings.lastRouteChangeWasPopstate()) |
| 105 currentSection.scrollIntoView(); | 108 currentSection.scrollIntoView(); |
| 106 } | 109 } |
| 107 | 110 |
| 108 // When this animation ends, another may be necessary. Call this function | 111 // When this animation ends, another may be necessary. Call this function |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; | 301 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; |
| 299 } | 302 } |
| 300 } | 303 } |
| 301 }; | 304 }; |
| 302 | 305 |
| 303 /** @polymerBehavior */ | 306 /** @polymerBehavior */ |
| 304 var MainPageBehavior = [ | 307 var MainPageBehavior = [ |
| 305 settings.RouteObserverBehavior, | 308 settings.RouteObserverBehavior, |
| 306 MainPageBehaviorImpl, | 309 MainPageBehaviorImpl, |
| 307 ]; | 310 ]; |
| OLD | NEW |