0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed flash of site when portal preview is loading

no issue

- added `@invisibleUntilLoaded` boolean argument to `<GhSiteIframe>`
  - when set to true add `.invisible` class until iframe's `load` event is triggered
- removed manual iframe hiding with 1.2sec delay from portal settings modal
- added `@onLoad` argument to `<GhSiteIframe>` for consumers to hook in if needed
This commit is contained in:
Kevin Ansfield 2021-05-18 16:36:18 +01:00
parent b4a6eb594d
commit 602549097a
5 changed files with 18 additions and 9 deletions

View file

@ -1,8 +1,9 @@
<iframe <iframe
class="site-frame" class="site-frame {{if this.isInvisible "invisible"}}"
src={{this.srcUrl}} src={{this.srcUrl}}
frameborder="0" frameborder="0"
allowtransparency="true" allowtransparency="true"
{{did-update this.resetSrcAttribute @guid}} {{did-update this.resetSrcAttribute @guid}}
{{on "load" this.onLoad}}
...attributes ...attributes
></iframe> ></iframe>

View file

@ -1,10 +1,13 @@
import Component from '@glimmer/component'; import Component from '@glimmer/component';
import {action} from '@ember/object'; import {action} from '@ember/object';
import {inject as service} from '@ember/service'; import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
export default class GhSiteIframeComponent extends Component { export default class GhSiteIframeComponent extends Component {
@service config; @service config;
@tracked isInvisible = this.args.invisibleUntilLoaded;
get srcUrl() { get srcUrl() {
return this.args.src || `${this.config.get('blogUrl')}/`; return this.args.src || `${this.config.get('blogUrl')}/`;
} }
@ -20,4 +23,12 @@ export default class GhSiteIframeComponent extends Component {
} }
this._lastGuid = this.args.guid; this._lastGuid = this.args.guid;
} }
@action
onLoad(event) {
if (this.args.invisibleUntilLoaded) {
this.isInvisible = false;
}
this.args.onLoad?.(event);
}
} }

View file

@ -242,8 +242,9 @@
<div class="gh-portal-preview-container {{if this.showLinksPage "hide"}}"> <div class="gh-portal-preview-container {{if this.showLinksPage "hide"}}">
<div class="gh-portal-site-frame-cover"> </div> <div class="gh-portal-site-frame-cover"> </div>
<GhSiteIframe <GhSiteIframe
class="gh-portal-siteiframe"
@src={{this.portalPreviewUrl}} @src={{this.portalPreviewUrl}}
class="gh-portal-siteiframe {{if this.hidePreviewFrame "invisible"}}" /> @invisibleUntilLoaded={{true}} />
</div> </div>
</div> </div>

View file

@ -88,7 +88,6 @@ export default ModalComponent.extend({
init() { init() {
this._super(...arguments); this._super(...arguments);
this.set('hidePreviewFrame', true);
this.buttonStyleOptions = [ this.buttonStyleOptions = [
{name: 'icon-and-text', label: 'Icon and text'}, {name: 'icon-and-text', label: 'Icon and text'},
{name: 'icon-only', label: 'Icon only'}, {name: 'icon-only', label: 'Icon only'},
@ -108,11 +107,6 @@ export default ModalComponent.extend({
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.settings.get('errors').clear(); this.settings.get('errors').clear();
run.later(this, function () {
if (!this.isDestroyed && !this.isDestroying) {
this.set('hidePreviewFrame', false);
}
}, 1200);
}, },
actions: { actions: {

View file

@ -51,7 +51,9 @@
{{#if (eq this.settings.membersSignupAccess 'none')}} {{#if (eq this.settings.membersSignupAccess 'none')}}
PORTAL DISABLED PORTAL DISABLED
{{else}} {{else}}
<GhSiteIframe @src={{this.portalPreviewUrl}} /> <GhSiteIframe
@src={{this.portalPreviewUrl}}
@invisibleUntilLoaded={{true}} />
{{/if}} {{/if}}
</div> </div>
</div> </div>