Set horizontal margin for even better consistency
This commit is contained in:
@@ -15,7 +15,7 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||
const contentWidth = el.offsetWidth;
|
||||
const contentHeight = el.offsetHeight;
|
||||
|
||||
const LEFT_MARGIN = 2;
|
||||
const HORIZONTAL_MARGIN = 1;
|
||||
|
||||
let rect: DOMRect;
|
||||
|
||||
@@ -38,10 +38,10 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||
left -= (el.offsetWidth / 2);
|
||||
|
||||
if (left + contentWidth - window.scrollX > window.innerWidth) {
|
||||
left = window.innerWidth - contentWidth + window.scrollX - 1;
|
||||
left = window.innerWidth - contentWidth + window.scrollX - HORIZONTAL_MARGIN;
|
||||
}
|
||||
|
||||
left = Math.max(LEFT_MARGIN, left);
|
||||
left = Math.max(HORIZONTAL_MARGIN, left);
|
||||
|
||||
return [left, top];
|
||||
};
|
||||
@@ -61,10 +61,10 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||
left -= (el.offsetWidth / 2);
|
||||
|
||||
if (left + contentWidth - window.scrollX > window.innerWidth) {
|
||||
left = window.innerWidth - contentWidth + window.scrollX - 1;
|
||||
left = window.innerWidth - contentWidth + window.scrollX - HORIZONTAL_MARGIN;
|
||||
}
|
||||
|
||||
left = Math.max(LEFT_MARGIN, left);
|
||||
left = Math.max(HORIZONTAL_MARGIN, left);
|
||||
|
||||
return [left, top];
|
||||
};
|
||||
@@ -81,7 +81,7 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||
top = props.y;
|
||||
}
|
||||
|
||||
left = Math.max(LEFT_MARGIN, left);
|
||||
left = Math.max(HORIZONTAL_MARGIN, left);
|
||||
|
||||
top -= (el.offsetHeight / 2);
|
||||
|
||||
@@ -114,7 +114,7 @@ export function calcPopupPosition(el: HTMLElement, props: {
|
||||
top -= (el.offsetHeight / 2);
|
||||
}
|
||||
|
||||
left = Math.max(LEFT_MARGIN, left);
|
||||
left = Math.max(HORIZONTAL_MARGIN, left);
|
||||
|
||||
if (top + contentHeight - window.scrollY > window.innerHeight) {
|
||||
top = window.innerHeight - contentHeight + window.scrollY - 1;
|
||||
|
||||
Reference in New Issue
Block a user