Chromium Code Reviews| 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. |