提交 8f96f0cf 编写于 作者: M Matt Bierner

Fix scroll position not being restored on release notes

Fixes #45571
上级 84ed12fb
......@@ -99,7 +99,7 @@
return;
}
const progress = event.target.body.scrollTop / event.target.body.clientHeight;
const progress = event.currentTarget.scrollY / event.target.body.clientHeight;
if (isNaN(progress)) {
return;
}
......@@ -312,10 +312,10 @@
var setInitialScrollPosition;
if (firstLoad) {
firstLoad = false;
setInitialScrollPosition = (body) => {
setInitialScrollPosition = (body, window) => {
if (!isNaN(initData.initialScrollProgress)) {
if (body.scrollTop === 0) {
body.scrollTop = body.clientHeight * initData.initialScrollProgress;
window.scroll(0, body.clientHeight * initData.initialScrollProgress);
}
}
};
......@@ -323,7 +323,7 @@
const scrollY = frame && frame.contentDocument && frame.contentDocument.body ? frame.contentDocument.body.scrollTop : 0;
setInitialScrollPosition = (body) => {
if (body.scrollTop === 0) {
body.scrollTop = scrollY;
window.scroll(0, scrollY);
}
};
}
......@@ -360,7 +360,7 @@
if (contentDocument.body) {
// Workaround for https://github.com/Microsoft/vscode/issues/12865
// check new scrollTop and reset if neccessary
setInitialScrollPosition(contentDocument.body);
setInitialScrollPosition(contentDocument.body, contentWindow);
// Bubble out link clicks
contentDocument.body.addEventListener('click', handleInnerClick);
......
......@@ -184,14 +184,13 @@ export class WebviewEditor extends BaseWebviewEditor {
private updateWebview(input: WebviewEditorInput) {
const webview = this.getWebview(input);
input.claimWebview(this);
webview.options = {
webview.update(input.html, {
allowScripts: input.options.enableScripts,
allowSvgs: true,
enableWrappedPostMessage: true,
useSameOriginForRoot: false,
localResourceRoots: input.options.localResourceRoots || this.getDefaultLocalResourceRoots()
};
input.html = input.html;
});
if (this._webviewContent) {
this._webviewContent.style.visibility = 'visible';
......
......@@ -267,6 +267,16 @@ export class WebviewElement extends Disposable {
});
}
public update(value: string, options: WebviewOptions) {
this._contents = value;
this._options = options;
this._send('content', {
contents: this._contents,
options: this._options,
state: this._state
});
}
public set baseUrl(value: string) {
this._send('baseUrl', value);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册