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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 // Finish by restoring the section into the page. | 280 // Finish by restoring the section into the page. |
| 281 section.setFrozen(false); | 281 section.setFrozen(false); |
| 282 return Promise.resolve(); | 282 return Promise.resolve(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // Play the actual collapse animation. | 285 // Play the actual collapse animation. |
| 286 return new Promise(function(resolve, reject) { | 286 return new Promise(function(resolve, reject) { |
| 287 // Wait for the other sections to show up so we can scroll properly. | 287 // Wait for the other sections to show up so we can scroll properly. |
| 288 setTimeout(function() { | 288 setTimeout(function() { |
| 289 var newSection = settings.getCurrentRoute().section && | 289 var newSection = settings.getCurrentRoute().section && |
| 290 !settings.getCurrentRoute().isSubpage() && | |
|
michaelpg
2017/03/29 01:11:21
I think this would be clearer as part of the "if"
tommycli
2017/03/29 16:27:21
Done.
| |
| 290 this.getSection(settings.getCurrentRoute().section); | 291 this.getSection(settings.getCurrentRoute().section); |
| 291 | 292 |
| 292 // Scroll to the new section or the original position. | 293 // Scroll to the new section or the original position. |
| 293 if (newSection && !settings.lastRouteChangeWasPopstate()) | 294 if (newSection && !settings.lastRouteChangeWasPopstate()) |
| 294 newSection.scrollIntoView(); | 295 newSection.scrollIntoView(); |
| 295 else | 296 else |
| 296 this.scroller.scrollTop = this.origScrollTop_; | 297 this.scroller.scrollTop = this.origScrollTop_; |
| 297 | 298 |
| 298 this.currentAnimation_ = section.animateCollapse( | 299 this.currentAnimation_ = section.animateCollapse( |
| 299 /** @type {!HTMLElement} */(this.scroller)); | 300 /** @type {!HTMLElement} */(this.scroller)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 return /** @type {?SettingsSectionElement} */( | 339 return /** @type {?SettingsSectionElement} */( |
| 339 this.$$('settings-section[section="' + section + '"]')); | 340 this.$$('settings-section[section="' + section + '"]')); |
| 340 }, | 341 }, |
| 341 }; | 342 }; |
| 342 | 343 |
| 343 /** @polymerBehavior */ | 344 /** @polymerBehavior */ |
| 344 var MainPageBehavior = [ | 345 var MainPageBehavior = [ |
| 345 settings.RouteObserverBehavior, | 346 settings.RouteObserverBehavior, |
| 346 MainPageBehaviorImpl, | 347 MainPageBehaviorImpl, |
| 347 ]; | 348 ]; |
| OLD | NEW |