fix: limit tooltip size for left and right location (#8055)
Some checks are pending
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2025-02-19 17:55:50 +07:00 committed by GitHub
parent 4b44eca734
commit 7bdb4de5b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -151,23 +151,30 @@
else dir = 'top' else dir = 'top'
} else dir = $tooltip.direction } else dir = $tooltip.direction
const left = rectAnchor.x + rectAnchor.width / 2
const maxWidth = Math.min(left, docWidth - left)
if (dir === 'right') { if (dir === 'right') {
const maxWidth = Math.min(docWidth / 2, docWidth - rectAnchor.right)
options.top = rectAnchor.y + rectAnchor.height / 2 + 'px' options.top = rectAnchor.y + rectAnchor.height / 2 + 'px'
options.left = `calc(${rectAnchor.right}px + .75rem)` options.left = `calc(${rectAnchor.right}px + .75rem)`
options.maxWidth = `calc(${maxWidth}px - 1.5rem)`
options.transform = 'translateY(-50%)' options.transform = 'translateY(-50%)'
} else if (dir === 'left') { } else if (dir === 'left') {
const maxWidth = Math.min(docWidth / 2, docWidth - rectAnchor.x)
options.top = rectAnchor.y + rectAnchor.height / 2 + 'px' options.top = rectAnchor.y + rectAnchor.height / 2 + 'px'
options.right = `calc(${docWidth - rectAnchor.x}px + .75rem)` options.right = `calc(${docWidth - rectAnchor.x}px + .75rem)`
options.maxWidth = `calc(${maxWidth}px - 1.5rem)`
options.transform = 'translateY(-50%)' options.transform = 'translateY(-50%)'
} else if (dir === 'bottom') { } else if (dir === 'bottom') {
const left = rectAnchor.x + rectAnchor.width / 2
const maxWidth = Math.min(left, docWidth - left)
options.top = `calc(${rectAnchor.bottom}px + .5rem)` options.top = `calc(${rectAnchor.bottom}px + .5rem)`
options.left = rectAnchor.x + rectAnchor.width / 2 + 'px' options.left = rectAnchor.x + rectAnchor.width / 2 + 'px'
options.maxWidth = `calc(${maxWidth * 2}px - 1.5rem)` options.maxWidth = `calc(${maxWidth * 2}px - 1.5rem)`
options.transform = 'translateX(-50%)' options.transform = 'translateX(-50%)'
} else if (dir === 'top') { } else if (dir === 'top') {
const left = rectAnchor.x + rectAnchor.width / 2
const maxWidth = Math.min(left, docWidth - left)
options.bottom = `calc(${docHeight - rectAnchor.y}px + .75rem)` options.bottom = `calc(${docHeight - rectAnchor.y}px + .75rem)`
options.left = rectAnchor.x + rectAnchor.width / 2 + 'px' options.left = rectAnchor.x + rectAnchor.width / 2 + 'px'
options.maxWidth = `calc(${maxWidth * 2}px - 1.5rem)` options.maxWidth = `calc(${maxWidth * 2}px - 1.5rem)`