Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions extensions/amp-story-shopping/0.1/amp-story-shopping-attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export class AmpStoryShoppingAttachment extends AMP.BaseElement {

/** @override */
buildCallback() {
if (this.shoppingTags_.length === 0) {
Comment thread
processprocess marked this conversation as resolved.
return;
}
Services.extensionsFor(this.win).installExtensionForDoc(
this.getAmpDoc(),
'amp-story-page-attachment',
'0.1'
);
loadFonts(this.win, FONTS_TO_LOAD);
this.attachmentEl_ = (
<amp-story-page-attachment
Expand All @@ -74,6 +82,9 @@ export class AmpStoryShoppingAttachment extends AMP.BaseElement {

/** @override */
layoutCallback() {
if (this.shoppingTags_.length === 0) {
return;
}
this.storeService_.subscribe(
StateProperty.PAGE_ATTACHMENT_STATE,
(isOpen) => this.onPageAttachmentStateUpdate_(isOpen)
Expand Down
18 changes: 6 additions & 12 deletions extensions/amp-story/1.0/amp-story-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export class AmpStoryPage extends AMP.BaseElement {

this.muteAllMedia();

this.renderOpenAttachmentUI_();
this.installPageAttachmentExtension_();

return Promise.all([
this.waitForMediaLayout_().then(() => this.markPageAsLoaded_()),
Expand Down Expand Up @@ -1523,21 +1523,15 @@ export class AmpStoryPage extends AMP.BaseElement {
}

/**
* Renders the open attachment UI affordance.
* Installs the page attachment extension.
* @private
*/
renderOpenAttachmentUI_() {
// AttachmentEl can be any component that extends draggable drawer.
const attachmentEl = this.element.querySelector(
'amp-story-page-attachment, amp-story-page-outlink, amp-story-shopping-attachment'
installPageAttachmentExtension_() {
const elementsThatRequireExtension = this.element.querySelector(
'amp-story-page-attachment, amp-story-page-outlink'
Comment thread
jshamble marked this conversation as resolved.
Outdated
);

if (
!attachmentEl ||
(attachmentEl.tagName === 'AMP-STORY-SHOPPING-ATTACHMENT' &&
this.element.getElementsByTagName('amp-story-shopping-tag').length ===
0)
) {
if (!elementsThatRequireExtension) {
return;
}

Expand Down