Fixed design settings preview losing scroll position when changing settings

refs https://github.com/TryGhost/Team/issues/1149

- replicated the visible iframe's `scrollTop` to the hidden iframe before swapping visibility between them so the scroll position remains consistent even though the contents and frames are fully reloaded and swapped
This commit is contained in:
Kevin Ansfield 2021-10-19 13:52:38 +01:00
parent 552412d323
commit 977e4d55f4

View File

@ -62,6 +62,7 @@ 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;
this.iframes[this.toRenderIframe].style = this.visibleIframeStyle;
this.renderedIframe = this.toRenderIframe;
this.toRenderIframe = this.toRenderIframe === 0 ? 1 : 0;