Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,18 +745,25 @@ export class App extends Protocol<Request, Notification, Result> {
*/
setupSizeChangeNotifications() {
let scheduled = false;

const sendBodySizeChange = () => {
if (scheduled) {
return;
}
scheduled = true;
requestAnimationFrame(() => {
scheduled = false;
const rect = (
document.body.parentElement ?? document.body
).getBoundingClientRect();
const width = Math.ceil(rect.width);
const height = Math.ceil(rect.height);
const el = document.body.parentElement ?? document.body;
const rect = el.getBoundingClientRect();
// Compensate for viewport scrollbar on Linux/Windows where scrollbars
// consume space. window.innerWidth includes scrollbar, clientWidth excludes it.
const scrollbarWidth =
window.innerWidth - document.documentElement.clientWidth;
// Use max of rect (includes CSS transforms) and scroll dimensions (content overflow).
const width = Math.ceil(
Math.max(rect.width, el.scrollWidth) + scrollbarWidth,
);
const height = Math.ceil(Math.max(rect.height, el.scrollHeight));
this.sendSizeChange({ width, height });
});
};
Expand Down