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 99dbc67c6181c689a6c3d63067f450ed323534c5..f4ce0b32dbfa6c45cde7eb2e34e34c78c0c64701 100644 |
| --- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js |
| +++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js |
| @@ -309,12 +309,14 @@ var MainPageBehaviorImpl = { |
| }, |
| }; |
| + |
| /** @polymerBehavior */ |
| var MainPageBehavior = [ |
| TransitionBehavior, |
| MainPageBehaviorImpl |
| ]; |
| + |
| /** |
| * TODO(michaelpg): integrate slide animations. |
| * @polymerBehavior RoutableBehavior |
| @@ -329,13 +331,24 @@ var RoutableBehaviorImpl = { |
| }, |
| }, |
| + /** |
| + * @param {string} section Name of the item to scroll into view. |
| + */ |
| + scrollToSection: function(section) { |
| + if (section) { |
| + // TODO(dschuyler): Determine whether this setTimeout can be removed. |
|
michaelpg
2016/04/29 20:19:04
I filed Polymer/polymer#3629 so you can link to th
dschuyler
2016/04/29 21:27:45
Done.
|
| + setTimeout(function() { |
| + var element = this.getSection_(section); |
| + if (element) |
|
michaelpg
2016/04/29 20:19:04
Looks like this should be an assert.
dschuyler
2016/04/29 21:27:45
Done. I removed the 'if' and made this one line.
|
| + element.scrollIntoView(); |
| + }.bind(this)); |
| + } |
| + }, |
| + |
| /** @private */ |
| currentRouteChanged_: function(newRoute, oldRoute) { |
| - // route.section is only non-empty when the user is within a subpage. |
| - // When the user is not in a subpage, but on the Basic page, route.section |
| - // is an empty string. |
| - var newRouteIsSubpage = newRoute && newRoute.section; |
| - var oldRouteIsSubpage = oldRoute && oldRoute.section; |
| + var newRouteIsSubpage = newRoute && newRoute.subpage.length; |
| + var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length; |
| if (!oldRoute && newRouteIsSubpage) { |
| // Allow the page to load before expanding the section. TODO(michaelpg): |
| @@ -357,6 +370,8 @@ var RoutableBehaviorImpl = { |
| var section = this.getSection_(newRoute.section); |
| if (section) |
| this.expandSection(section); |
| + } else if (newRoute && newRoute.section) { |
| + this.scrollToSection(newRoute.section); |
| } |
| }, |
| @@ -372,6 +387,7 @@ var RoutableBehaviorImpl = { |
| }, |
| }; |
| + |
| /** @polymerBehavior */ |
| var RoutableBehavior = [ |
| MainPageBehavior, |