Skip to content

Commit

Permalink
Add the core amp-story component (#11511)
Browse files Browse the repository at this point in the history
* Add the core amp-story component

* Add TODO LDAP

* Update amp-story.css

* Update amp-story.js

* Fix eslint errors in amp-story.js and add back experiment

* Fix lint errors in test-amp-story.js

* amp-story.js lint changes

* Update test-amp-story.js

* Update amp-story.js

* Update amp-story.js

* Add @const where possible.

* Add fixes for various integration points that broke during merges.

* Remove renamed 'AnalyticsTrigger'

* Add missing trailing comma to test file

* Update closure type annotations.

* Remove double nullability indicators

* Explicitly import animation typedefs.

* Update typedefs for animation-types

* Partial fixes for closure type issues

* Partial fixes for closure type issues (part 2)

* Partial fixes for closure type issues (part 3)

* Remove extra whitespace

* Partial fixes for closure type issues (part 4)

* Fix missing imports and typos

* Fix missing imports and typos

* Fix remaining type issues

* Skip failing amp-story tests; fix loading screen when no elements require loading.
  • Loading branch information
newmuis authored and William Chou committed Oct 4, 2017
1 parent 41a640f commit afd6ebd
Show file tree
Hide file tree
Showing 18 changed files with 1,627 additions and 138 deletions.
22 changes: 12 additions & 10 deletions extensions/amp-story/0.1/amp-story-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ export class AmpStoryPage extends AMP.BaseElement {
constructor(element) {
super(element);

/** @private @const {?AnimationManager} */
/** @private {?AnimationManager} */
this.animationManager_ = null;

/** @private @const {!Array<!PageElement>} */
/** @private {!Array<!PageElement>} */
this.pageElements_ = [];

/** @private {?function()} */
Expand Down Expand Up @@ -215,6 +215,7 @@ export class AmpStoryPage extends AMP.BaseElement {
markPageAsLoaded_() {
this.isLoaded_ = true;
this.element.classList.add(PAGE_LOADED_CLASS_NAME);
this.markPageAsShown_();
this.resolveLoadPromise_();
}

Expand Down Expand Up @@ -248,7 +249,7 @@ export class AmpStoryPage extends AMP.BaseElement {
* @public
*/
calculateLoadStatus() {
if (this.isLoaded_) {
if (this.isLoaded_ || this.pageElements_.length == 0) {
return true;
}

Expand Down Expand Up @@ -451,21 +452,22 @@ export class AmpStoryPage extends AMP.BaseElement {
/**
* Determines whether the specified element is a valid media element for auto-
* advance.
* @param {?Element} el
* @param {?Element} elOrNull
* @param {!function()} callback
* @private
*/
onMediaElementComplete_(el, callback) {
user().assertElement(el, 'ID specified for automatic advance ' +
`does not refer to any element on page '${this.element.id}'.`);
onMediaElementComplete_(elOrNull, callback) {
const el = user().assertElement(elOrNull,
'ID specified for automatic advance does not refer to any element' +
`on page '${this.element.id}'.`);

const mediaElement = this.getMediaElement_(el);
if (mediaElement) {
this.autoAdvanceUnlistenDef_ =
listenOnce(mediaElement, 'ended', callback);
} else if (this.isVideoInterfaceVideo_(el)) {
this.autoAdvanceUnlistenDef_ =
listenOnce(el, VideoEvents.ENDED, callback, /* opt_capture */ true);
listenOnce(el, VideoEvents.ENDED, callback, {capture: true});
} else {
user().error(TAG, `Element with ID ${el.id} is not a media element ` +
'supported for automatic advancement.');
Expand Down Expand Up @@ -602,8 +604,8 @@ export class AmpStoryPage extends AMP.BaseElement {

/**
* Navigates to the next page in the story.
* @param {*} opt_isAutomaticAdvance Whether this navigation was caused by an
* automatic advancement after a timeout.
* @param {boolean} opt_isAutomaticAdvance Whether this navigation was caused
* by an automatic advancement after a timeout.
*/
next(opt_isAutomaticAdvance) {
this.switchTo_(
Expand Down
Loading

0 comments on commit afd6ebd

Please sign in to comment.