mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Copy width & height from the ResizeObserver callback (#201406)
Copy width & height from the ResizeObserver callback to avoid "ResizeObserver loop completed with undelivered notifications" error (fixes microsoft/monaco-editor#4311)
This commit is contained in:
parent
30b7773127
commit
58041888f4
|
@ -47,10 +47,10 @@ export class ElementSizeObserver extends Disposable {
|
|||
// Otherwise we will postpone to the next animation frame.
|
||||
// We'll use `observeContentRect` to store the content rect we received.
|
||||
|
||||
let observeContentRect: DOMRectReadOnly | null = null;
|
||||
let observedDimenstion: IDimension | null = null;
|
||||
const observeNow = () => {
|
||||
if (observeContentRect) {
|
||||
this.observe({ width: observeContentRect.width, height: observeContentRect.height });
|
||||
if (observedDimenstion) {
|
||||
this.observe({ width: observedDimenstion.width, height: observedDimenstion.height });
|
||||
} else {
|
||||
this.observe();
|
||||
}
|
||||
|
@ -75,7 +75,11 @@ export class ElementSizeObserver extends Disposable {
|
|||
};
|
||||
|
||||
this._resizeObserver = new ResizeObserver((entries) => {
|
||||
observeContentRect = (entries && entries[0] && entries[0].contentRect ? entries[0].contentRect : null);
|
||||
if (entries && entries[0] && entries[0].contentRect) {
|
||||
observedDimenstion = { width: entries[0].contentRect.width, height: entries[0].contentRect.height };
|
||||
} else {
|
||||
observedDimenstion = null;
|
||||
}
|
||||
shouldObserve = true;
|
||||
update();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue