Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4210)

Unified Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2201553002: [MD settings] only add overscroll if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: described math Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..84592638a81d2d3c5b48653374f0f12a904c7ffc 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();
+
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,19 @@ Polymer({
return 0;
}
- // Ensure any dom-if reflects the current properties.
- Polymer.dom.flush();
-
- /**
- * @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);
- }
+ 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);
- assert(this.showPages_.basic);
- var lastSection = this.$$('settings-basic-page').$$(
- 'settings-section:last-of-type');
- // |lastSection| may be null in unit tests.
- if (!lastSection)
+ if (!topSection)
return 0;
- var toggleContainer = this.$$('#toggleContainer');
- return calcHeight(lastSection) -
- (toggleContainer ? toggleContainer.offsetHeight : 0);
+
+ // Offset to the selected section (relative to the scrolling window).
+ let sectionTop = topSection.offsetParent.offsetTop + topSection.offsetTop;
+ // The height of the selected section and remaining content (sections).
+ let heightOfShownSections = this.$.overscroll.offsetTop - sectionTop;
+ return Math.max(0, this.parentNode.scrollHeight - heightOfShownSections);
},
/** @private */
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698