| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 this.getSection(settings.getCurrentRoute().section); | 290 this.getSection(settings.getCurrentRoute().section); |
| 291 | 291 |
| 292 // Scroll to the new section or the original position. | 292 // Scroll to the new section or the original position. |
| 293 if (newSection && !settings.lastRouteChangeWasPopstate()) | 293 if (newSection && !settings.lastRouteChangeWasPopstate() && |
| 294 !settings.getCurrentRoute().isSubpage()) { |
| 294 newSection.scrollIntoView(); | 295 newSection.scrollIntoView(); |
| 295 else | 296 } else { |
| 296 this.scroller.scrollTop = this.origScrollTop_; | 297 this.scroller.scrollTop = this.origScrollTop_; |
| 298 } |
| 297 | 299 |
| 298 this.currentAnimation_ = section.animateCollapse( | 300 this.currentAnimation_ = section.animateCollapse( |
| 299 /** @type {!HTMLElement} */(this.scroller)); | 301 /** @type {!HTMLElement} */(this.scroller)); |
| 300 | 302 |
| 301 this.currentAnimation_.finished.catch(function() { | 303 this.currentAnimation_.finished.catch(function() { |
| 302 // The collapse was canceled, so the page is showing a subpage still. | 304 // The collapse was canceled, so the page is showing a subpage still. |
| 303 this.fire('subpage-expand'); | 305 this.fire('subpage-expand'); |
| 304 }.bind(this)).then(function() { | 306 }.bind(this)).then(function() { |
| 305 // Clean up after the animation succeeds or cancels. | 307 // Clean up after the animation succeeds or cancels. |
| 306 section.setFrozen(false); | 308 section.setFrozen(false); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return /** @type {?SettingsSectionElement} */( | 340 return /** @type {?SettingsSectionElement} */( |
| 339 this.$$('settings-section[section="' + section + '"]')); | 341 this.$$('settings-section[section="' + section + '"]')); |
| 340 }, | 342 }, |
| 341 }; | 343 }; |
| 342 | 344 |
| 343 /** @polymerBehavior */ | 345 /** @polymerBehavior */ |
| 344 var MainPageBehavior = [ | 346 var MainPageBehavior = [ |
| 345 settings.RouteObserverBehavior, | 347 settings.RouteObserverBehavior, |
| 346 MainPageBehaviorImpl, | 348 MainPageBehaviorImpl, |
| 347 ]; | 349 ]; |
| OLD | NEW |