Fix UWP positioning of popovers

This commit is contained in:
Jaifroid 2024-05-17 17:55:52 +01:00
parent 5984f28aef
commit 414e076300

View File

@ -1636,13 +1636,16 @@ function attachKiwixPopoverDiv (ev, link, articleBaseUrl, dark) {
var linkRect = link.getBoundingClientRect();
// Initially position the div 20px above the link
var triangleDirection = 'top';
var divRectY = (linkRect.top - div.offsetHeight - 20);
var divOffsetHeight = /UWP/.test(params.appType) ? div.offsetHeight * params.relativeFontSize / 100 + 20 : div.offsetHeight - 20;
var divRectY = linkRect.top - divOffsetHeight;
if (/UWP/.test(params.appType)) divRectY = (divRectY * 100 / params.relativeFontSize);
var triangleY = divHeight + 6;
// If we're less than half margin from the top, move the div below the link
if (divRectY < margin / 2) {
triangleDirection = 'bottom';
divRectY = linkRect.bottom + 20;
triangleY = -16;
if (/UWP/.test(params.appType)) divRectY = divRectY * 100 / params.relativeFontSize;
}
// Position it horizontally in relation to the pointer position
var divRectX, triangleX;