Skip to content

Commit

Permalink
Defer building system layer until pages have been initialized (#11878)
Browse files Browse the repository at this point in the history
* Change progress bar to not handle active page, since active page updates progress bar through PAGE_PROGRESS events

* Revert "Change progress bar to not handle active page, since active page updates progress bar through PAGE_PROGRESS events"

This reverts commit 0500899.

* Defer building system layer until pages have been initialized.
  • Loading branch information
newmuis authored and alanorozco committed Nov 1, 2017
1 parent 8528de7 commit ab5175d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions extensions/amp-story/0.1/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ export class AmpStory extends AMP.BaseElement {
this.lockBody_();
}

this.element.appendChild(
this.systemLayer_.build(this.getRealChildren().length));

this.initializeListeners_();
this.initializeListenersForDev_();

Expand All @@ -193,6 +190,16 @@ export class AmpStory extends AMP.BaseElement {
}


/**
* Builds the system layer DOM. This is dependent on the pages_ array having
* been initialized, so it cannot happen at build time.
* @private
*/
buildSystemLayer_() {
this.element.appendChild(this.systemLayer_.build(this.getPageCount()));
}


/** @private */
initializeListeners_() {
this.element.addEventListener(EventType.EXIT_FULLSCREEN, () => {
Expand Down Expand Up @@ -350,6 +357,7 @@ export class AmpStory extends AMP.BaseElement {
'Story must have at least one page.');

return this.initializePages_()
.then(() => this.buildSystemLayer_())
.then(() => {
this.pages_.forEach(page => {
page.setActive(false);
Expand Down

0 comments on commit ab5175d

Please sign in to comment.