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 ebf7979202f47c74c35f0c9da95ee93ee8e50158..a6fea45484811505946a9eeb010cb99d04d0d4b0 100644 |
| --- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js |
| +++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js |
| @@ -25,13 +25,20 @@ var MainPageBehaviorImpl = { |
| * @param {settings.Route} oldRoute |
| */ |
| currentRouteChanged: function(newRoute, oldRoute) { |
| + // Scroll to the section for any non-popstate navigation. Also scroll for |
| + // any popstate navigations that are in-page. |
|
Dan Beam
2016/11/15 01:24:22
this is kinda confusing. "Scroll to the section e
tommycli
2016/11/15 21:18:23
Done.
|
| + var oldRouteWasSection = oldRoute && oldRoute.parent && oldRoute.section && |
| + oldRoute.parent.section != oldRoute.section; |
| + var scrollToSection = |
| + !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; |
|
Dan Beam
2016/11/15 01:24:21
nit: 2 more spaces
tommycli
2016/11/15 21:18:23
Done.
|
| + |
| // If this is the first route, or the page was hidden, allow the page to |
| // render before expanding the section. |
| if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || |
| this.scrollHeight == 0) { |
| - setTimeout(this.tryTransitionToSection_.bind(this)); |
| + setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| } else { |
| - this.tryTransitionToSection_(); |
| + this.tryTransitionToSection_(scrollToSection); |
| } |
| }, |
| @@ -41,9 +48,10 @@ var MainPageBehaviorImpl = { |
| * that one, then schedules this function again. This ensures the current |
| * section is quickly shown, without getting the page into a broken state -- |
| * if currentRoute changes in between calls, just transition to the new route. |
| + * @param {boolean} scrollToSection |
| * @private |
| */ |
| - tryTransitionToSection_: function() { |
| + tryTransitionToSection_: function(scrollToSection) { |
| var currentRoute = settings.getCurrentRoute(); |
| var currentSection = this.getSection(currentRoute.section); |
| @@ -63,7 +71,7 @@ var MainPageBehaviorImpl = { |
| if (!currentRoute.isSubpage() || expandedSection != currentSection) { |
| promise = this.collapseSection_(expandedSection); |
| // Scroll to the collapsed section. |
| - if (currentSection && !settings.lastRouteChangeWasPopstate()) |
| + if (currentSection && scrollToSection) |
| currentSection.scrollIntoView(); |
| } else { |
| // Scroll to top while sliding to another subpage. |
| @@ -73,14 +81,14 @@ var MainPageBehaviorImpl = { |
| // Expand the section into a subpage or scroll to it on the main page. |
| if (currentRoute.isSubpage()) |
| promise = this.expandSection_(currentSection); |
| - else if (!settings.lastRouteChangeWasPopstate()) |
| + else if (scrollToSection) |
| currentSection.scrollIntoView(); |
| } |
| // When this animation ends, another may be necessary. Call this function |
| // again after the promise resolves. |
| if (promise) |
| - promise.then(this.tryTransitionToSection_.bind(this)); |
| + promise.then(this.tryTransitionToSection_.bind(this, scrollToSection)); |
| }, |
| /** |