mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
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:
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user