cache panel body size

fixes #60018
This commit is contained in:
Joao Moreno 2018-10-10 11:28:19 +02:00
parent d729e50521
commit febf978c28

View file

@ -46,7 +46,6 @@ export abstract class Panel implements IView {
protected _expanded: boolean;
protected disposables: IDisposable[] = [];
private expandedSize: number | undefined = undefined;
private _headerVisible = true;
private _minimumBodySize: number;
private _maximumBodySize: number;
@ -55,6 +54,9 @@ export abstract class Panel implements IView {
private header: HTMLElement;
private cachedExpandedSize: number | undefined = undefined;
private cachedBodySize: number | undefined = undefined;
private _onDidChange = new Emitter<number | undefined>();
readonly onDidChange: Event<number | undefined> = this._onDidChange.event;
@ -129,7 +131,7 @@ export abstract class Panel implements IView {
this._expanded = !!expanded;
this.updateHeader();
this._onDidChange.fire(expanded ? this.expandedSize : undefined);
this._onDidChange.fire(expanded ? this.cachedExpandedSize : undefined);
}
get headerVisible(): boolean {
@ -190,8 +192,14 @@ export abstract class Panel implements IView {
const headerSize = this.headerVisible ? Panel.HEADER_SIZE : 0;
if (this.isExpanded()) {
this.layoutBody(size - headerSize);
this.expandedSize = size;
const bodySize = size - headerSize;
if (bodySize !== this.cachedBodySize) {
this.layoutBody(bodySize);
this.cachedBodySize = bodySize;
}
this.cachedExpandedSize = size;
}
}