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

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

Issue 2259163002: MD Settings: Fix scrolling bugs and hacks caused by undefined load behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TransitionsNoTestsFakeRebase
Patch Set: bug fixes 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
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 c29e84e4eae8489097e081b78599acdd06b8bc1e..fdd87038d2442adfcfc9a114d41f96b78929911d 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -48,12 +48,7 @@ Polymer({
* Controls which main pages are displayed via dom-ifs.
* @private {!MainPageVisibility}
*/
- showPages_: {
- type: Object,
- value: function() {
- return {about: false, basic: false, advanced: false};
- },
- },
+ showPages_: Object,
/**
* The main pages that were displayed before search was initiated. When
@@ -107,7 +102,11 @@ Polymer({
this.boundScroll_ = null;
} else if (this.overscroll_ && !this.boundScroll_) {
this.boundScroll_ = this.setOverscroll_.bind(this, 0);
- this.offsetParent.addEventListener('scroll', this.boundScroll_);
+ // Do not react immediately to scroll events since the overscroll was
+ // just set; we may be trying to scroll somewhere first.
+ setTimeout(function() {
michaelpg 2016/08/19 04:40:45 I wish I didn't have to do this, but when we route
dschuyler 2016/08/23 02:09:50 would afterNextRender help any better?
michaelpg 2016/09/29 01:12:48 Ended up not needing this.
+ this.offsetParent.addEventListener('scroll', this.boundScroll_);
+ }.bind(this));
}
},
@@ -171,6 +170,8 @@ Polymer({
* @private
*/
updatePagesShown_: function() {
+ var oldShowPages = this.showPages_;
+
var currentRoute = settings.getCurrentRoute();
if (settings.Route.ABOUT.contains(currentRoute)) {
this.showPages_ = {about: true, basic: false, advanced: false};
@@ -190,13 +191,27 @@ 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();
+ // Initialize the overscroll after rendering a page.
+ if (!oldShowPages)
+ setTimeout(this.updateOverscroll_.bind(this));
+ else
+ this.updateOverscroll_();
+ },
+
+ /**
+ * Sets the overscroll synchronously and asynchronously, to avoid
+ * preventing or conflicting with other DOM changes.
+ * @private
+ */
+ updateOverscroll_: function() {
+ // Update the overscroll padding so pages can scroll to section.
+ this.setOverscroll_(this.overscrollHeight_());
+ // Wait for any other changes to page height, then calculate the overflow
+ // padding again.
+ this.async(function() {
this.setOverscroll_(this.overscrollHeight_());
- }.bind(this));
+ });
},
/**
« no previous file with comments | « chrome/browser/resources/settings/settings.html ('k') | chrome/browser/resources/settings/settings_page/main_page_behavior.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698