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

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

Issue 2228783005: MD Settings: Never underscroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@RefactorMainPageBehavior2
Patch Set: rebase Created 4 years, 4 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 cfcfbfd01560985c35800aba2aedb5b0363cc3ee..47b3d98dedb00fefd5961c3194c8f4f85a07af3e 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -97,24 +97,30 @@ Polymer({
/** @private */
overscrollChanged_: function() {
if (!this.overscroll_ && this.boundScroll_) {
- this.parentNode.scroller.removeEventListener('scroll', this.boundScroll_);
+ this.offsetParent.removeEventListener('scroll', this.boundScroll_);
this.boundScroll_ = null;
} else if (this.overscroll_ && !this.boundScroll_) {
- this.boundScroll_ = this.scrollEventListener_.bind(this);
- this.parentNode.scroller.addEventListener('scroll', this.boundScroll_);
+ this.boundScroll_ = this.setOverscroll_.bind(this, 0);
+ this.offsetParent.addEventListener('scroll', this.boundScroll_);
}
},
- /** @private */
- scrollEventListener_: function() {
- var scroller = this.parentNode.scroller;
+ /**
+ * Sets the overscroll padding. Never forces a scroll, i.e., always leaves
+ * any currently visible overflow as-is.
+ * @param {number=} opt_minHeight The minimum overscroll height needed.
+ */
+ setOverscroll_: function(opt_minHeight) {
+ var scroller = this.offsetParent;
+ if (!scroller)
+ return;
var overscroll = this.$.overscroll;
var visibleBottom = scroller.scrollTop + scroller.clientHeight;
var overscrollBottom = overscroll.offsetTop + overscroll.scrollHeight;
// How much of the overscroll is visible (may be negative).
var visibleOverscroll = overscroll.scrollHeight -
(overscrollBottom - visibleBottom);
- this.overscroll_ = Math.max(0, visibleOverscroll);
+ this.overscroll_ = Math.max(opt_minHeight || 0, visibleOverscroll);
},
/**
@@ -162,7 +168,7 @@ Polymer({
// Ensure any dom-if reflects the current properties.
Polymer.dom.flush();
- this.overscroll_ = this.overscrollHeight_();
+ this.setOverscroll_(this.overscrollHeight_());
}.bind(this));
},
@@ -176,19 +182,19 @@ Polymer({
*/
overscrollHeight_: function() {
var route = settings.getCurrentRoute();
- if (route.isSubpage() || this.showPages_.about)
+ if (!route.section || route.isSubpage() || this.showPages_.about)
return 0;
var page = this.getPage_(route);
- var topSection = page && page.getSection(route.section);
- if (!topSection || !topSection.offsetParent)
+ var section = page && page.getSection(route.section);
+ if (!section || !section.offsetParent)
return 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);
+ // Find the distance from the section's top to the overscroll.
+ var sectionTop = section.offsetParent.offsetTop + section.offsetTop;
+ var distance = this.$.overscroll.offsetTop - sectionTop;
+
+ return Math.max(0, this.offsetParent.clientHeight - distance);
},
/** @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