| 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 331e9d54a37f39ef8f16161775c86c7b93002edb..04b70c9784d8b3f9a3d046c19254eb6ed891801a 100644
|
| --- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js
|
| +++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
|
| @@ -92,10 +92,17 @@ var MainPageBehaviorImpl = {
|
|
|
| // For previously uncreated pages (including on first load), allow the page
|
| // to render before scrolling to or expanding the section.
|
| - if (!oldRoute || this.scrollHeight == 0)
|
| + if (!oldRoute) {
|
| + this.fire('hide-container');
|
| + setTimeout(function() {
|
| + this.fire('show-container');
|
| + this.tryTransitionToSection_(scrollToSection, true);
|
| + }.bind(this));
|
| + } else if (this.scrollHeight == 0) {
|
| setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
|
| - else
|
| + } else {
|
| this.tryTransitionToSection_(scrollToSection);
|
| + }
|
| },
|
|
|
| /**
|
| @@ -118,9 +125,10 @@ var MainPageBehaviorImpl = {
|
| * 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
|
| + * @param {boolean=} immediate Whether to instantly expand instead of animate.
|
| * @private
|
| */
|
| - tryTransitionToSection_: function(scrollToSection) {
|
| + tryTransitionToSection_: function(scrollToSection, immediate) {
|
| var currentRoute = settings.getCurrentRoute();
|
| var currentSection = this.getSection(currentRoute.section);
|
|
|
| @@ -145,10 +153,14 @@ var MainPageBehaviorImpl = {
|
| }
|
| } 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 if (scrollToSection)
|
| + if (currentRoute.isSubpage()) {
|
| + if (immediate)
|
| + this.expandSectionImmediate_(currentSection);
|
| + else
|
| + promise = this.expandSection_(currentSection);
|
| + } else if (scrollToSection) {
|
| currentSection.scrollIntoView();
|
| + }
|
| } else if (
|
| this.tagName == 'SETTINGS-BASIC-PAGE' &&
|
| settings.Route.ADVANCED.contains(currentRoute) &&
|
| @@ -156,13 +168,19 @@ var MainPageBehaviorImpl = {
|
| // ADVANCED, otherwise tryTransitionToSection_ will recurse endlessly.
|
| !currentRoute.isNavigableDialog) {
|
| assert(currentRoute.section);
|
| + // Hide the container again while Advanced Page template is being loaded.
|
| + this.fire('hide-container');
|
| promise = this.$$('#advancedPageTemplate').get();
|
| }
|
|
|
| // When this animation ends, another may be necessary. Call this function
|
| // again after the promise resolves.
|
| - if (promise)
|
| - promise.then(this.tryTransitionToSection_.bind(this, scrollToSection));
|
| + if (promise) {
|
| + promise.then(this.tryTransitionToSection_.bind(this, scrollToSection))
|
| + .then(function() {
|
| + this.fire('show-container');
|
| + }.bind(this));
|
| + }
|
| },
|
|
|
| /**
|
| @@ -204,6 +222,19 @@ var MainPageBehaviorImpl = {
|
| },
|
|
|
| /**
|
| + * Immediately expand the card in |section| to fill the page.
|
| + * @param {!SettingsSectionElement} section
|
| + * @private
|
| + */
|
| + expandSectionImmediate_: function(section) {
|
| + assert(this.scroller);
|
| + section.immediateExpand(this.scroller);
|
| + this.finishedExpanding_(section);
|
| + // TODO(scottchen): iron-list inside subpages need this to render correctly.
|
| + this.fire('resize');
|
| + },
|
| +
|
| + /**
|
| * Animates the card in |section|, expanding it to fill the page.
|
| * @param {!SettingsSectionElement} section
|
| * @return {!Promise} Resolved when the transition is finished or canceled.
|
| @@ -211,7 +242,6 @@ var MainPageBehaviorImpl = {
|
| */
|
| expandSection_: function(section) {
|
| assert(this.scroller);
|
| -
|
| if (!section.canAnimateExpand()) {
|
| // Try to wait for the section to be created.
|
| return new Promise(function(resolve, reject) {
|
| @@ -228,28 +258,33 @@ var MainPageBehaviorImpl = {
|
|
|
| this.currentAnimation_ = section.animateExpand(this.scroller);
|
|
|
| - var finished;
|
| - return this.currentAnimation_.finished.then(function() {
|
| - // Hide other sections and scroll to the top of the subpage.
|
| - this.classList.add('showing-subpage');
|
| - this.toggleOtherSectionsHidden_(section.section, true);
|
| - this.scroller.scrollTop = 0;
|
| - section.setFrozen(false);
|
| -
|
| - // Notify that the page is fully expanded.
|
| - this.fire('subpage-expand');
|
| + return this.currentAnimation_.finished
|
| + .then(
|
| + function() {
|
| + this.finishedExpanding_(section);
|
| + }.bind(this),
|
| + function() {
|
| + // The animation was canceled; restore the section and scroll
|
| + // position.
|
| + section.setFrozen(false);
|
| + this.scroller.scrollTop = this.origScrollTop_;
|
| + }.bind(this))
|
| + .then(function() {
|
| + this.fire('freeze-scroll', false);
|
| + this.currentAnimation_ = null;
|
| + }.bind(this));
|
| + },
|
|
|
| - finished = true;
|
| - }.bind(this), function() {
|
| - // The animation was canceled; restore the section and scroll position.
|
| - section.setFrozen(false);
|
| - this.scroller.scrollTop = this.origScrollTop_;
|
| + /** @private */
|
| + finishedExpanding_: function(section) {
|
| + // Hide other sections and scroll to the top of the subpage.
|
| + this.classList.add('showing-subpage');
|
| + this.toggleOtherSectionsHidden_(section.section, true);
|
| + this.scroller.scrollTop = 0;
|
| + section.setFrozen(false);
|
|
|
| - finished = false;
|
| - }.bind(this)).then(function() {
|
| - this.fire('freeze-scroll', false);
|
| - this.currentAnimation_ = null;
|
| - }.bind(this));
|
| + // Notify that the page is fully expanded.
|
| + this.fire('subpage-expand');
|
| },
|
|
|
| /**
|
|
|