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

Unified Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2274693003: [MD settings] scroll to section from URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_page/main_page_behavior.js
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.js b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
index 7eeedf2318f8baba885c85a8e24b2ff6e9d94707..64c3eba76a47395e2ec34c03f06d4399e4c6aabc 100644
--- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js
+++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
@@ -44,10 +44,15 @@ var MainPageBehaviorImpl = {
currentRouteChanged: function(newRoute, oldRoute) {
// Allow the page to load before expanding the section. TODO(michaelpg):
// Time this better when refactoring settings-animated-pages.
- if (!oldRoute && newRoute.isSubpage())
+ if (!oldRoute && newRoute.isSubpage()) {
setTimeout(this.tryTransitionToSection_.bind(this));
- else
- this.tryTransitionToSection_();
+ } else {
+ doWhenReady(
michaelpg 2016/08/24 22:01:59 can we change doWhenReady to run the callback imme
+ function() {
+ return this.scrollHeight > 0;
+ }.bind(this),
+ this.tryTransitionToSection_.bind(this));
+ }
},
/**
@@ -82,14 +87,14 @@ var MainPageBehaviorImpl = {
// based on the current scroll position. This bug existed before, and is
// fixed in the next patch by making the card position: absolute.
if (currentSection)
- this.scrollToSection_();
+ currentSection.scrollIntoView();
}
} else if (currentSection) {
// Expand the section into a subpage or scroll to it on the main page.
if (currentRoute.isSubpage())
promise = this.expandSection_(currentSection);
else
- this.scrollToSection_();
+ currentSection.scrollIntoView();
}
// When this animation ends, another may be necessary. Call this function
@@ -216,21 +221,6 @@ var MainPageBehaviorImpl = {
section.hidden = hidden && (section.section != sectionName);
},
- /** @private */
- scrollToSection_: function() {
- doWhenReady(
- function() {
- return this.scrollHeight > 0;
- }.bind(this),
- function() {
- // If the current section changes while we are waiting for the page to
- // be ready, scroll to the newest requested section.
- var section = this.getSection(settings.getCurrentRoute().section);
- if (section)
- section.scrollIntoView();
- }.bind(this));
- },
-
/**
* Helper function to get a section from the local DOM.
* @param {string} section Section name of the element to get.
« 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