chore: upgrade lexical & make linting/formatting consistent with web codebase (#2144)
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
const VERTICAL_GAP = 10;
|
||||
const HORIZONTAL_OFFSET = 5;
|
||||
const VERTICAL_GAP = 10
|
||||
const HORIZONTAL_OFFSET = 5
|
||||
|
||||
export function setFloatingElemPosition(
|
||||
targetRect: ClientRect | null,
|
||||
@@ -15,32 +15,32 @@ export function setFloatingElemPosition(
|
||||
verticalGap: number = VERTICAL_GAP,
|
||||
horizontalOffset: number = HORIZONTAL_OFFSET,
|
||||
): void {
|
||||
const scrollerElem = anchorElem.parentElement;
|
||||
const scrollerElem = anchorElem.parentElement
|
||||
|
||||
if (targetRect === null || !scrollerElem) {
|
||||
floatingElem.style.opacity = '0';
|
||||
floatingElem.style.transform = 'translate(-10000px, -10000px)';
|
||||
return;
|
||||
floatingElem.style.opacity = '0'
|
||||
floatingElem.style.transform = 'translate(-10000px, -10000px)'
|
||||
return
|
||||
}
|
||||
|
||||
const floatingElemRect = floatingElem.getBoundingClientRect();
|
||||
const anchorElementRect = anchorElem.getBoundingClientRect();
|
||||
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
||||
const floatingElemRect = floatingElem.getBoundingClientRect()
|
||||
const anchorElementRect = anchorElem.getBoundingClientRect()
|
||||
const editorScrollerRect = scrollerElem.getBoundingClientRect()
|
||||
|
||||
let top = targetRect.top - floatingElemRect.height - verticalGap;
|
||||
let left = targetRect.left - horizontalOffset;
|
||||
let top = targetRect.top - floatingElemRect.height - verticalGap
|
||||
let left = targetRect.left - horizontalOffset
|
||||
|
||||
if (top < editorScrollerRect.top) {
|
||||
top += floatingElemRect.height + targetRect.height + verticalGap * 2;
|
||||
top += floatingElemRect.height + targetRect.height + verticalGap * 2
|
||||
}
|
||||
|
||||
if (left + floatingElemRect.width > editorScrollerRect.right) {
|
||||
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
|
||||
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset
|
||||
}
|
||||
|
||||
top -= anchorElementRect.top;
|
||||
left -= anchorElementRect.left;
|
||||
top -= anchorElementRect.top
|
||||
left -= anchorElementRect.left
|
||||
|
||||
floatingElem.style.opacity = '1';
|
||||
floatingElem.style.transform = `translate(${left}px, ${top}px)`;
|
||||
floatingElem.style.opacity = '1'
|
||||
floatingElem.style.transform = `translate(${left}px, ${top}px)`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user