mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Allow changing horizontal offset of popover
This commit is contained in:
parent
c3c7f8b14f
commit
4582be1da5
@ -111,9 +111,10 @@ function repositionContainer() {
|
|||||||
|
|
||||||
const containerBounds = containerElement.getBoundingClientRect();
|
const containerBounds = containerElement.getBoundingClientRect();
|
||||||
const containerInlinePadding = parseInt(containerComputedStyle.getPropertyValue("padding-inline"));
|
const containerInlinePadding = parseInt(containerComputedStyle.getPropertyValue("padding-inline"));
|
||||||
const targetBoundsWidthOffset = targetBounds.width * (activeTarget.dataset.popoverOffset || 0.5);
|
const targetBoundsWidthOffset = targetBounds.width * (activeTarget.dataset.popoverTargetOffset || 0.5);
|
||||||
const position = activeTarget.dataset.popoverPosition || "below";
|
const position = activeTarget.dataset.popoverPosition || "below";
|
||||||
const left = Math.round(targetBounds.left + targetBoundsWidthOffset - (containerBounds.width / 2));
|
const popoverOffest = activeTarget.dataset.popoverOffset || 0.5;
|
||||||
|
const left = Math.round(targetBounds.left + targetBoundsWidthOffset - (containerBounds.width * popoverOffest));
|
||||||
|
|
||||||
if (left < 0) {
|
if (left < 0) {
|
||||||
containerElement.style.left = 0;
|
containerElement.style.left = 0;
|
||||||
@ -126,7 +127,7 @@ function repositionContainer() {
|
|||||||
} else {
|
} else {
|
||||||
containerElement.style.removeProperty("right");
|
containerElement.style.removeProperty("right");
|
||||||
containerElement.style.left = left + "px";
|
containerElement.style.left = left + "px";
|
||||||
containerElement.style.removeProperty("--triangle-offset");
|
containerElement.style.setProperty("--triangle-offset", ((targetBounds.left + targetBoundsWidthOffset) - left - containerInlinePadding) + "px");
|
||||||
}
|
}
|
||||||
|
|
||||||
const distanceFromTarget = activeTarget.dataset.popoverMargin || defaultDistanceFromTarget;
|
const distanceFromTarget = activeTarget.dataset.popoverMargin || defaultDistanceFromTarget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user