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

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

Issue 2206723002: [MD settings] shrink overscroll when scrolling up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge with master 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 | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | 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 62a76e1a425eae45f5ceeeba7fde9f381c50c372..30eb744895e2bfcd570189da2d7104532ef06f75 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -37,6 +37,12 @@ Polymer({
/** @private */
inSubpage_: Boolean,
+ /** @private */
+ overscroll_: {
+ type: Number,
+ observer: 'overscrollChanged_',
+ },
+
/**
* Controls which main pages are displayed via dom-ifs.
* @type {!{about: boolean, basic: boolean, advanced: boolean}}
@@ -78,6 +84,30 @@ Polymer({
settings.navigateTo(this.advancedToggleExpanded_ ?
settings.Route.ADVANCED : settings.Route.BASIC);
}.bind(this));
+
+ },
+
+ /** @private */
+ overscrollChanged_: function() {
+ if (!this.overscroll_ && this.boundScroll_) {
+ this.parentNode.scroller.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_);
+ }
+ },
+
+ /** @private */
+ scrollEventListener_: function() {
+ var scroller = this.parentNode.scroller;
+ 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);
Dan Beam 2016/08/03 22:04:59 if this could share more with overscrollHeight_ th
dschuyler 2016/08/03 22:26:03 I think the math looks similar off the cuff. I don
},
/**
@@ -128,7 +158,7 @@ Polymer({
// Ensure any dom-if reflects the current properties.
Polymer.dom.flush();
- this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px';
+ this.overscroll_ = this.overscrollHeight_();
}.bind(this));
},
« no previous file with comments | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698