| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 * @param {settings.Route} oldRoute | 52 * @param {settings.Route} oldRoute |
| 53 */ | 53 */ |
| 54 currentRouteChanged: function(newRoute, oldRoute) { | 54 currentRouteChanged: function(newRoute, oldRoute) { |
| 55 // Allow the page to load before expanding the section. TODO(michaelpg): | 55 // Allow the page to load before expanding the section. TODO(michaelpg): |
| 56 // Time this better when refactoring settings-animated-pages. | 56 // Time this better when refactoring settings-animated-pages. |
| 57 if (!oldRoute && newRoute.isSubpage()) { | 57 if (!oldRoute && newRoute.isSubpage()) { |
| 58 setTimeout(this.tryTransitionToSection_.bind(this)); | 58 setTimeout(this.tryTransitionToSection_.bind(this)); |
| 59 } else { | 59 } else { |
| 60 doWhenReady( | 60 doWhenReady( |
| 61 function() { | 61 function() { |
| 62 if (this.scrollHeight > 0) | 62 return this.scrollHeight > 0 || |
| 63 return true; | 63 !settings.Route[this.route].contains(settings.getCurrentRoute()); |
| 64 | |
| 65 // Height is irrelevant if this page isn't the current page. | |
| 66 if (!settings.Route[this.route].contains(settings.getCurrentRoute())) | |
| 67 return true; | |
| 68 | |
| 69 return false; | |
| 70 }.bind(this), | 64 }.bind(this), |
| 71 this.tryTransitionToSection_.bind(this)); | 65 this.tryTransitionToSection_.bind(this)); |
| 72 } | 66 } |
| 73 }, | 67 }, |
| 74 | 68 |
| 75 /** | 69 /** |
| 76 * If possible, transitions to the current route's section (by expanding or | 70 * If possible, transitions to the current route's section (by expanding or |
| 77 * scrolling to it). If another transition is running, finishes or cancels | 71 * scrolling to it). If another transition is running, finishes or cancels |
| 78 * that one, then schedules this function again. This ensures the current | 72 * that one, then schedules this function again. This ensures the current |
| 79 * section is quickly shown, without getting the page into a broken state -- | 73 * section is quickly shown, without getting the page into a broken state -- |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; | 304 this.scroller.style.width = 'calc(100% - ' + scrollbarWidth + 'px)'; |
| 311 } | 305 } |
| 312 } | 306 } |
| 313 }; | 307 }; |
| 314 | 308 |
| 315 /** @polymerBehavior */ | 309 /** @polymerBehavior */ |
| 316 var MainPageBehavior = [ | 310 var MainPageBehavior = [ |
| 317 settings.RouteObserverBehavior, | 311 settings.RouteObserverBehavior, |
| 318 MainPageBehaviorImpl, | 312 MainPageBehaviorImpl, |
| 319 ]; | 313 ]; |
| OLD | NEW |