Update App.tsx

This commit is contained in:
zsviczian 2024-09-28 13:05:40 +02:00 committed by GitHub
parent a977dd1bf5
commit 5c8adfa1a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3857,40 +3857,53 @@ class App extends React.Component<AppProps, AppState> {
public getEditorUIOffsets = (): Offsets => { public getEditorUIOffsets = (): Offsets => {
const toolbarBottom = const toolbarBottom =
this.excalidrawContainerRef?.current (this.excalidrawContainerRef?.current
?.querySelector(".App-toolbar") ?.querySelector(".App-toolbar")
?.getBoundingClientRect()?.bottom ?? 0; ?.getBoundingClientRect()?.bottom ?? 0) - this.state.offsetTop;
const sidebarRect = this.excalidrawContainerRef?.current const sidebarRect = this.excalidrawContainerRef?.current
?.querySelector(".sidebar") ?.querySelector(".sidebar")
?.getBoundingClientRect(); ?.getBoundingClientRect();
const propertiesPanelRect = this.excalidrawContainerRef?.current const propertiesPanelRect = this.excalidrawContainerRef?.current
?.querySelector(".App-menu__left") ?.querySelector(".App-menu__left")
?.getBoundingClientRect(); ?.getBoundingClientRect();
const PADDING = 16; const PADDING = 16;
const adjustRectValueForOffset = (
value: number | undefined,
fallback: number,
) => (value ?? fallback + this.state.offsetLeft) - this.state.offsetLeft;
return getLanguage().rtl return getLanguage().rtl
? { ? {
top: toolbarBottom + PADDING, top: toolbarBottom + PADDING,
right: right:
Math.max( Math.max(
this.state.width - this.state.width -
(propertiesPanelRect?.left ?? this.state.width), adjustRectValueForOffset(
propertiesPanelRect?.left,
this.state.width,
),
0, 0,
) + PADDING, ) + PADDING,
bottom: PADDING, bottom: PADDING,
left: Math.max(sidebarRect?.right ?? 0, 0) + PADDING, left:
Math.max(adjustRectValueForOffset(sidebarRect?.right, 0), 0) +
PADDING,
} }
: { : {
top: toolbarBottom + PADDING, top: toolbarBottom + PADDING,
right: Math.max( right: Math.max(
this.state.width - this.state.width -
(sidebarRect?.left ?? this.state.width) + adjustRectValueForOffset(sidebarRect?.left, this.state.width) +
PADDING, PADDING,
0, 0,
), ),
bottom: PADDING, bottom: PADDING,
left: Math.max(propertiesPanelRect?.right ?? 0, 0) + PADDING, left:
Math.max(
adjustRectValueForOffset(propertiesPanelRect?.right, 0),
0,
) + PADDING,
}; };
}; };