| 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 // Fast out, slow in. | 5 // Fast out, slow in. |
| 6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; | 6 var EASING_FUNCTION = 'cubic-bezier(0.4, 0, 0.2, 1)'; |
| 7 var EXPAND_DURATION = 350; | 7 var EXPAND_DURATION = 350; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Calls |readyTest| repeatedly until it returns true, then calls | 10 * Calls |readyTest| repeatedly until it returns true, then calls |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 TransitionBehavior, | 346 TransitionBehavior, |
| 347 MainPageBehaviorImpl | 347 MainPageBehaviorImpl |
| 348 ]; | 348 ]; |
| 349 | 349 |
| 350 | 350 |
| 351 /** | 351 /** |
| 352 * TODO(michaelpg): integrate slide animations. | 352 * TODO(michaelpg): integrate slide animations. |
| 353 * @polymerBehavior RoutableBehavior | 353 * @polymerBehavior RoutableBehavior |
| 354 */ | 354 */ |
| 355 var RoutableBehaviorImpl = { | 355 var RoutableBehaviorImpl = { |
| 356 properties: { | |
| 357 /** Contains the current route. */ | |
| 358 currentRoute: { | |
| 359 type: Object, | |
| 360 notify: true, | |
| 361 observer: 'currentRouteChanged_', | |
| 362 }, | |
| 363 }, | |
| 364 | |
| 365 /** @private */ | 356 /** @private */ |
| 366 scrollToSection_: function() { | 357 scrollToSection_: function() { |
| 367 doWhenReady( | 358 doWhenReady( |
| 368 function() { | 359 function() { |
| 369 return this.scrollHeight > 0; | 360 return this.scrollHeight > 0; |
| 370 }.bind(this), | 361 }.bind(this), |
| 371 function() { | 362 function() { |
| 372 // If the current section changes while we are waiting for the page to | 363 // If the current section changes while we are waiting for the page to |
| 373 // be ready, scroll to the newest requested section. | 364 // be ready, scroll to the newest requested section. |
| 374 this.getSection_(this.currentRoute.section).scrollIntoView(); | 365 this.getSection_(settings.getCurrentRoute().section).scrollIntoView(); |
| 375 }.bind(this)); | 366 }.bind(this)); |
| 376 }, | 367 }, |
| 377 | 368 |
| 378 /** @private */ | 369 /** @private */ |
| 379 currentRouteChanged_: function(newRoute, oldRoute) { | 370 currentRouteChanged: function(newRoute, oldRoute) { |
| 380 var newRouteIsSubpage = newRoute && newRoute.subpage.length; | 371 var newRouteIsSubpage = newRoute && newRoute.subpage.length; |
| 381 var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length; | 372 var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length; |
| 382 | 373 |
| 383 if (!oldRoute && newRouteIsSubpage) { | 374 if (!oldRoute && newRouteIsSubpage) { |
| 384 // Allow the page to load before expanding the section. TODO(michaelpg): | 375 // Allow the page to load before expanding the section. TODO(michaelpg): |
| 385 // Time this better when refactoring settings-animated-pages. | 376 // Time this better when refactoring settings-animated-pages. |
| 386 setTimeout(function() { | 377 setTimeout(function() { |
| 387 var section = this.getSection_(newRoute.section); | 378 var section = this.getSection_(newRoute.section); |
| 388 if (section) | 379 if (section) |
| 389 this.expandSection(section); | 380 this.expandSection(section); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 419 getSection_: function(section) { | 410 getSection_: function(section) { |
| 420 return /** @type {?SettingsSectionElement} */( | 411 return /** @type {?SettingsSectionElement} */( |
| 421 this.$$('[section=' + section + ']')); | 412 this.$$('[section=' + section + ']')); |
| 422 }, | 413 }, |
| 423 }; | 414 }; |
| 424 | 415 |
| 425 | 416 |
| 426 /** @polymerBehavior */ | 417 /** @polymerBehavior */ |
| 427 var RoutableBehavior = [ | 418 var RoutableBehavior = [ |
| 428 MainPageBehavior, | 419 MainPageBehavior, |
| 420 settings.RouteObserverBehavior, |
| 429 RoutableBehaviorImpl | 421 RoutableBehaviorImpl |
| 430 ]; | 422 ]; |
| OLD | NEW |