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 95ebfc6a5404287d9b6b9711d98c04c73ec9bffe..c9056f0b78f053746390dfc4b1d46a098dca6ad2 100644 |
--- a/chrome/browser/resources/settings/settings_main/settings_main.js |
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js |
@@ -141,12 +141,15 @@ Polymer({ |
// Wait for any other changes prior to calculating the overflow padding. |
setTimeout(function() { |
+ // Ensure any dom-if reflects the current properties. |
+ Polymer.dom.flush(); |
dschuyler
2016/07/30 00:46:29
I moved this to keep all the timeout/flush
('is th
|
+ |
this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; |
}.bind(this)); |
}, |
/** |
- * Return the height that the over scroll padding should be set to. |
+ * Return the height that the overscroll 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. |
@@ -159,39 +162,17 @@ Polymer({ |
return 0; |
} |
- // Ensure any dom-if reflects the current properties. |
- Polymer.dom.flush(); |
+ var query = 'settings-section[section="' + this.currentRoute.section + '"]'; |
+ var topSection = this.$$('settings-basic-page').$$(query); |
+ if (!topSection && this.showPages_.advanced) |
+ topSection = this.$$('settings-advanced-page').$$(query); |
- /** |
- * @param {!Element} element |
- * @return {number} |
- */ |
- var calcHeight = function(element) { |
- var style = getComputedStyle(element); |
- var height = this.parentNode.scrollHeight - element.offsetHeight + |
- parseFloat(style.marginTop) + parseFloat(style.marginBottom); |
- assert(height >= 0); |
- return height; |
- }.bind(this); |
- |
- if (this.showPages_.advanced) { |
- var lastSection = this.$$('settings-advanced-page').$$( |
- 'settings-section:last-of-type'); |
- // |lastSection| may be null in unit tests. |
- if (!lastSection) |
- return 0; |
- return calcHeight(lastSection); |
+ if (topSection) { |
+ return Math.max(0, |
+ this.parentNode.scrollHeight - |
+ (this.$.overscroll.offsetTop - |
+ (topSection.offsetParent.offsetTop + topSection.offsetTop))); |
} |
- |
- assert(this.showPages_.basic); |
- var lastSection = this.$$('settings-basic-page').$$( |
- 'settings-section:last-of-type'); |
- // |lastSection| may be null in unit tests. |
- if (!lastSection) |
- return 0; |
- var toggleContainer = this.$$('#toggleContainer'); |
- return calcHeight(lastSection) - |
- (toggleContainer ? toggleContainer.offsetHeight : 0); |
}, |
/** @private */ |