mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Fixed offer screen portal preview height
refs https://github.com/TryGhost/Team/issues/1137 - adds dynamic height calculation based on portal events for offer portal preview
This commit is contained in:
parent
0619b10720
commit
b8d1dc8deb
1 changed files with 21 additions and 2 deletions
|
@ -183,10 +183,29 @@ export default class OffersController extends Controller {
|
|||
}
|
||||
|
||||
@action
|
||||
portalPreviewInserted() {}
|
||||
portalPreviewInserted(iframe) {
|
||||
this.portalPreviewIframe = iframe;
|
||||
|
||||
if (!this.portalMessageListener) {
|
||||
this.portalMessageListener = (event) => {
|
||||
const resizeEvents = ['portal-ready', 'portal-preview-updated'];
|
||||
if (resizeEvents.includes(event.data.type) && event.data.payload?.height) {
|
||||
this.portalPreviewIframe.parentNode.style.height = `${event.data.payload.height}px`;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', this.portalMessageListener, true);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
portalPreviewDestroyed() {}
|
||||
portalPreviewDestroyed() {
|
||||
this.portalPreviewIframe = null;
|
||||
|
||||
if (this.portalMessageListener) {
|
||||
window.removeEventListener('message', this.portalMessageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
updatePortalPreview({forceRefresh} = {forceRefresh: false}) {
|
||||
|
|
Loading…
Add table
Reference in a new issue