summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-11-22 10:42:58 +0000
committerdakkar <dakkar@thenautilus.net>2024-11-22 10:42:58 +0000
commitd069d78c213dfe2c78c1f160dbd99d48d0b44670 (patch)
tree4144ce79b89f5cb7026e71598eb85e1751742274 /packages/frontend/src/scripts
parentfix SCSS warning (diff)
parentmerge: Fix: Center SkModPlayer on big displays (!734) (diff)
downloadsharkey-d069d78c213dfe2c78c1f160dbd99d48d0b44670.tar.gz
sharkey-d069d78c213dfe2c78c1f160dbd99d48d0b44670.tar.bz2
sharkey-d069d78c213dfe2c78c1f160dbd99d48d0b44670.zip
Merge branch 'develop' into feature/2024.10
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/popup-position.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/frontend/src/scripts/popup-position.ts b/packages/frontend/src/scripts/popup-position.ts
index 3dad41a8b3..be49532cf8 100644
--- a/packages/frontend/src/scripts/popup-position.ts
+++ b/packages/frontend/src/scripts/popup-position.ts
@@ -15,6 +15,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
const contentWidth = el.offsetWidth;
const contentHeight = el.offsetHeight;
+ const HORIZONTAL_MARGIN = 1;
+
let rect: DOMRect;
if (props.anchorElement) {
@@ -36,9 +38,11 @@ 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(HORIZONTAL_MARGIN, left);
+
return [left, top];
};
@@ -57,9 +61,11 @@ 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(HORIZONTAL_MARGIN, left);
+
return [left, top];
};
@@ -75,6 +81,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
top = props.y;
}
+ left = Math.max(HORIZONTAL_MARGIN, left);
+
top -= (el.offsetHeight / 2);
if (top + contentHeight - window.scrollY > window.innerHeight) {
@@ -106,6 +114,8 @@ export function calcPopupPosition(el: HTMLElement, props: {
top -= (el.offsetHeight / 2);
}
+ left = Math.max(HORIZONTAL_MARGIN, left);
+
if (top + contentHeight - window.scrollY > window.innerHeight) {
top = window.innerHeight - contentHeight + window.scrollY - 1;
}