Skip to content

Commit

Permalink
Merge branch 'onetap' of github.com:kongguibin/amphtml into onetap
Browse files Browse the repository at this point in the history
  • Loading branch information
guibinkong authored and guibinkong committed Aug 7, 2020
2 parents f83b5c5 + 4f64474 commit 3606578
Show file tree
Hide file tree
Showing 4 changed files with 3,021 additions and 11 deletions.
8 changes: 8 additions & 0 deletions amp.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
1 change: 0 additions & 1 deletion extensions/amp-onetap-google/0.1/amp-onetap-google.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

amp-onetap-google.intermediate-iframe-card-mode {
margin: 0;
position: fixed;
right: 20px;
top: 20px;
Expand Down
26 changes: 16 additions & 10 deletions extensions/amp-onetap-google/0.1/amp-onetap-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ export class AmpOnetapGoogle extends AMP.BaseElement {
toWin(this.element.ownerDocument.defaultView)
);

/** @private {boolean=} */
this.isBottomSheetUiMode_ = undefined;
/** @private {?boolean} */
this.isBottomSheetUiMode_ = null;

/** @private {!Element=} */
this.intermediateIframe_;
/** @private {?Element} */
this.intermediateIframe_ = null;

/** @private {boolean} */
this.isIntermediateIframeVisible_ = false;
Expand Down Expand Up @@ -185,9 +185,17 @@ export class AmpOnetapGoogle extends AMP.BaseElement {
this.handleIntermediateIframeMessage_(event);
}
});
this.win.addEventListener('load', () => {
this.loadIntermediateIframe_();
});
if (document.readyState === 'complete') {
// window Load event has already been fired. Use set timeout to defer
// the call.
setTimeout(() => {
this.loadIntermediateIframe_();
}, 200);
} else {
this.win.addEventListener('load', function () {
this.loadIntermediateIframe_();
});
}
}

/**
Expand Down Expand Up @@ -256,7 +264,7 @@ export class AmpOnetapGoogle extends AMP.BaseElement {
});
break;
case ACTIONS.SET_UI_MODE:
if (this.isBottomSheetUiMode_ !== undefined) {
if (this.isBottomSheetUiMode_ !== null) {
return;
}
const uiMode = event.data['mode'];
Expand Down Expand Up @@ -331,7 +339,6 @@ export class AmpOnetapGoogle extends AMP.BaseElement {
this.element.appendChild(this.intermediateIframe_);
this.doc_.addEventListener('click', this.onClickOutside_, false);
this.setCardUiMode_();
console.log('Intermediate Iframe loaded.');
return true;
}
return false;
Expand All @@ -343,7 +350,6 @@ export class AmpOnetapGoogle extends AMP.BaseElement {
this.hideAmpElement_();
this.element.removeChild(this.intermediateIframe_);
this.intermediateIframe_ = null;
console.log('Intermediate Iframe unloaded.');
}
}

Expand Down
Loading

0 comments on commit 3606578

Please sign in to comment.