Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy width & height from the ResizeObserver callback #201406

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/vs/editor/browser/config/elementSizeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
});
Expand Down