提交 4b866982 编写于 作者: J Johannes Rieken

store and restore scrollTop when updating webview, #12865

上级 9d6f099b
......@@ -108,6 +108,9 @@
newDocument.body.appendChild(defaultScripts);
styleBody(newDocument.body);
// keep current scrollTop around and use later
const {scrollTop} = target.contentDocument.body;
// write new content onto iframe
target.contentDocument.open('text/html', 'replace');
// set DOCTYPE for newDocument explicitly as DOMParser.parseFromString strips it off
......@@ -116,6 +119,14 @@
target.contentDocument.write(newDocument.documentElement.innerHTML);
target.contentDocument.close();
// workaround for https://github.com/Microsoft/vscode/issues/12865
// check new scrollTop and reset if neccessary
setTimeout(() => {
if(scrollTop !== target.contentDocument.body.scrollTop) {
target.contentDocument.body.scrollTop = scrollTop;
}
}, 0);
ipcRenderer.sendToHost('did-set-content', stats);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册