mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Fixed design preview remembering scroll position when changing page
refs https://github.com/TryGhost/Team/issues/1149 - added a `@pageId` argument to `<GhHtmlIframe>`, if that value is different at the point of swapping iframes after re-rendering it will reset the scroll position instead of copying it from the to-be-hidden iframe - assigned `themeManagement.previewType` to `@pageId` so that it changes when switching between homepage and post previews
This commit is contained in:
parent
f2e8cc3926
commit
f66c992ad8
@ -62,7 +62,14 @@ export default class GhHtmlIframeComponent extends Component {
|
||||
window.clearTimeout(this.swapTimeout);
|
||||
|
||||
if (this.iframes.indexOf(renderedIframe) !== this.renderedIframe) {
|
||||
this.iframes[this.toRenderIframe].contentDocument.body.scrollTop = this.iframes[this.renderedIframe].contentDocument.body.scrollTop;
|
||||
let newScrollTop = this.iframes[this.renderedIframe].contentDocument.body.scrollTop;
|
||||
|
||||
if (this._lastPageId !== this.args.pageId) {
|
||||
newScrollTop = 0;
|
||||
}
|
||||
this._lastPageId = this.args.pageId;
|
||||
|
||||
this.iframes[this.toRenderIframe].contentDocument.body.scrollTop = newScrollTop;
|
||||
this.iframes[this.toRenderIframe].style = this.visibleIframeStyle;
|
||||
this.renderedIframe = this.toRenderIframe;
|
||||
this.toRenderIframe = this.toRenderIframe === 0 ? 1 : 0;
|
||||
|
@ -50,7 +50,7 @@
|
||||
{{/if}}
|
||||
<div class="{{if this.isMobilePreview "gh-pe-mobile-bezel" "gh-browserpreview-iframecontainer"}}">
|
||||
<div class="{{if this.isMobilePreview "gh-pe-mobile-screen"}}">
|
||||
<GhHtmlIframe class={{if this.isMobilePreview "gh-post-preview-iframe" "site-frame"}} @html={{this.themeManagement.previewHtml}} />
|
||||
<GhHtmlIframe class={{if this.isMobilePreview "gh-post-preview-iframe" "site-frame"}} @html={{this.themeManagement.previewHtml}} @pageId={{this.themeManagement.previewType}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user