Fix position of webviews and notebooks when the editor grid scrolls (#148858)

* Fix position of webviews and notebooks when the grid scrolls

Fixes #116946

Makes sure that absolutely positioned webviews and notebooks are correctly moved when the editor widget is scrolled

It also adds a clipping rect to make sure the elements do not overflow outside of the editor area (this would cause the webview/notebook to draw over the sidebar in some cases)

* Fix test service
This commit is contained in:
Matt Bierner
2022-05-06 11:49:33 -07:00
committed by GitHub
parent 10c8c1c2cc
commit 526505636e
9 changed files with 94 additions and 29 deletions

View File

@@ -1736,3 +1736,15 @@ export class DragAndDropObserver extends Disposable {
}));
}
}
export function computeClippingRect(elementOrRect: HTMLElement | DOMRectReadOnly, clipper: HTMLElement) {
const frameRect = (elementOrRect instanceof HTMLElement ? elementOrRect.getBoundingClientRect() : elementOrRect);
const rootRect = clipper.getBoundingClientRect();
const top = Math.max(rootRect.top - frameRect.top, 0);
const right = Math.max(frameRect.width - (frameRect.right - rootRect.right), 0);
const bottom = Math.max(frameRect.height - (frameRect.bottom - rootRect.bottom), 0);
const left = Math.max(rootRect.left - frameRect.left, 0);
return { top, right, bottom, left };
}