mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-29 00:46:00 +01:00
Move webview animation workaround to viewPane (#163675)
This workaround is only required for webview views, so let's move the code there
This commit is contained in:
@@ -31,7 +31,6 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
|
||||
private _html: string = '';
|
||||
private _initialScrollProgress: number = 0;
|
||||
private _state: string | undefined = undefined;
|
||||
private _repositionTimeout: any | undefined = undefined;
|
||||
|
||||
private _extension: WebviewExtensionDescription | undefined;
|
||||
private _contentOptions: WebviewContentOptions;
|
||||
@@ -85,8 +84,6 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
|
||||
}
|
||||
this._firstLoadPendingMessages.clear();
|
||||
|
||||
clearTimeout(this._repositionTimeout);
|
||||
|
||||
this._onDidDispose.fire();
|
||||
|
||||
super.dispose();
|
||||
@@ -163,17 +160,6 @@ export class OverlayWebview extends Disposable implements IOverlayWebview {
|
||||
}
|
||||
|
||||
public layoutWebviewOverElement(element: HTMLElement, dimension?: Dimension, clippingContainer?: HTMLElement) {
|
||||
this.doLayoutWebviewOverElement(element, dimension, clippingContainer);
|
||||
|
||||
// Temporary fix for https://github.com/microsoft/vscode/issues/110450
|
||||
// There is an animation that lasts about 200ms, update the webview positioning once this animation is complete.
|
||||
clearTimeout(this._repositionTimeout);
|
||||
this._repositionTimeout = setTimeout(() => {
|
||||
this.doLayoutWebviewOverElement(element, dimension, clippingContainer);
|
||||
}, 200);
|
||||
}
|
||||
|
||||
public doLayoutWebviewOverElement(element: HTMLElement, dimension?: Dimension, clippingContainer?: HTMLElement) {
|
||||
if (!this._container || !this._container.parentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ export class WebviewViewPane extends ViewPane {
|
||||
private readonly viewState: MementoObject;
|
||||
private readonly extensionId?: ExtensionIdentifier;
|
||||
|
||||
private _repositionTimeout?: any;
|
||||
|
||||
constructor(
|
||||
options: IViewletViewOptions,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@@ -110,6 +112,8 @@ export class WebviewViewPane extends ViewPane {
|
||||
override dispose() {
|
||||
this._onDispose.fire();
|
||||
|
||||
clearTimeout(this._repositionTimeout);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -286,16 +290,21 @@ export class WebviewViewPane extends ViewPane {
|
||||
return;
|
||||
}
|
||||
|
||||
webviewEntry.layoutWebviewOverElement(this._container);
|
||||
|
||||
if (!this._rootContainer || !this._rootContainer.isConnected) {
|
||||
this._rootContainer = this.findRootContainer(this._container);
|
||||
}
|
||||
|
||||
webviewEntry.layoutWebviewOverElement(this._container);
|
||||
|
||||
if (this._rootContainer) {
|
||||
const { top, left, right, bottom } = computeClippingRect(this._container, this._rootContainer);
|
||||
webviewEntry.container.style.clipPath = `polygon(${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px)`;
|
||||
}
|
||||
|
||||
// Temporary fix for https://github.com/microsoft/vscode/issues/110450
|
||||
// There is an animation that lasts about 200ms, update the webview positioning once this animation is complete.
|
||||
clearTimeout(this._repositionTimeout);
|
||||
this._repositionTimeout = setTimeout(() => this.layoutWebview(), 200);
|
||||
}
|
||||
|
||||
private findRootContainer(container: HTMLElement): HTMLElement | undefined {
|
||||
|
||||
Reference in New Issue
Block a user