Chromium Code Reviews| Index: chrome/browser/resources/settings/settings_main/settings_main.js |
| diff --git a/chrome/browser/resources/settings/settings_main/settings_main.js b/chrome/browser/resources/settings/settings_main/settings_main.js |
| index a5a6d10c5c551c74e652076ad17224e1cae42f98..a03188da07f9c802ea6f37c7d6e74ed7b2fd5dde 100644 |
| --- a/chrome/browser/resources/settings/settings_main/settings_main.js |
| +++ b/chrome/browser/resources/settings/settings_main/settings_main.js |
| @@ -138,6 +138,54 @@ Polymer({ |
| newRoute.page == 'advanced'; |
| this.style.height = isSubpage ? '100%' : ''; |
| + |
| + // Wait for the dom-if changes prior to calculating the overflow padding. |
| + this.async(function() { |
| + this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; |
| + }); |
| + }, |
| + |
| + /** |
| + * Return the height that the over scroll padding should be set to. |
| + * This is used to determine how much padding to apply to the end of the |
| + * content so that the last element may align with the top of the content |
| + * area. |
| + * @return {number} |
| + * @private |
| + */ |
| + overscrollHeight_: function() { |
| + if (!this.currentRoute || this.currentRoute.subpage.length != 0 || |
| + this.showAboutPage_) { |
| + return 0; |
| + } |
| + |
| + /** |
| + * @param {!Element} element |
| + * @return {number} |
| + */ |
| + function calcHeight(scrollHeight, element) { |
|
Dan Beam
2016/07/20 21:22:39
nit: missing a @param, BUT, can we just get this v
dschuyler
2016/07/21 00:14:23
That is nicer, thanks.
Done.
|
| + var style = getComputedStyle(element); |
| + var height = scrollHeight - element.offsetHeight + |
| + parseFloat(style.marginTop) + parseFloat(style.marginBottom); |
| + assert(height >= 0); |
| + return height; |
| + } |
| + |
| + var scrollHeight = this.parentNode.scrollHeight; |
| + |
| + if (this.showAdvancedPage_) { |
| + var lastSection = this.$$('settings-advanced-page').$$( |
| + 'settings-section:last-of-type'); |
| + // |lastSection| may be null in unit tests. |
| + if (lastSection) |
| + return calcHeight(scrollHeight, lastSection); |
| + } |
| + |
| + var toggleContainer = this.$$('#toggleContainer'); |
| + if (toggleContainer) |
| + return calcHeight(scrollHeight, toggleContainer); |
| + |
| + return 0; |
| }, |
| /** @private */ |