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 // 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 * Provides animations to expand and collapse individual sections in a page. | 10 * Provides animations to expand and collapse individual sections in a page. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 scrollToSection_: function() { | 339 scrollToSection_: function() { |
| 340 // TODO(dschuyler): Determine whether this setTimeout can be removed. | 340 // TODO(dschuyler): Determine whether this setTimeout can be removed. |
| 341 // See also: https://github.com/Polymer/polymer/issues/3629 | 341 // See also: https://github.com/Polymer/polymer/issues/3629 |
| 342 setTimeout(function pollForScrollHeight() { | 342 setTimeout(function pollForScrollHeight() { |
| 343 // If the current section changes while we are waiting for the page to be | 343 // If the current section changes while we are waiting for the page to be |
| 344 // ready, scroll to the newest requested section. | 344 // ready, scroll to the newest requested section. |
| 345 var element = this.getSection_(this.currentRoute.section); | 345 var element = this.getSection_(this.currentRoute.section); |
| 346 if (!element) | 346 if (!element) |
| 347 return; | 347 return; |
| 348 | 348 |
| 349 if (element.parentNode.host.scrollHeight == 0) { | 349 var host = findAncestor(element, function(n) { return n.host; }).host; |
|
michaelpg
2016/06/06 20:13:03
This is more complicated than necessary (this.scro
| |
| 350 if (host.scrollHeight == 0) { | |
| 350 setTimeout(pollForScrollHeight.bind(this), 100); | 351 setTimeout(pollForScrollHeight.bind(this), 100); |
| 351 return; | 352 return; |
| 352 } | 353 } |
| 353 | 354 |
| 354 element.scrollIntoView(); | 355 element.scrollIntoView(); |
| 355 }.bind(this)); | 356 }.bind(this)); |
| 356 }, | 357 }, |
| 357 | 358 |
| 358 /** @private */ | 359 /** @private */ |
| 359 currentRouteChanged_: function(newRoute, oldRoute) { | 360 currentRouteChanged_: function(newRoute, oldRoute) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 this.$$('[section=' + section + ']')); | 397 this.$$('[section=' + section + ']')); |
| 397 }, | 398 }, |
| 398 }; | 399 }; |
| 399 | 400 |
| 400 | 401 |
| 401 /** @polymerBehavior */ | 402 /** @polymerBehavior */ |
| 402 var RoutableBehavior = [ | 403 var RoutableBehavior = [ |
| 403 MainPageBehavior, | 404 MainPageBehavior, |
| 404 RoutableBehaviorImpl | 405 RoutableBehaviorImpl |
| 405 ]; | 406 ]; |
| OLD | NEW |