mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +00:00
TSK-1312: refit tooltip after loading components inside it (#3083)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
da2a7ec9c6
commit
60702a48d2
@ -44,8 +44,8 @@
|
|||||||
''
|
''
|
||||||
}
|
}
|
||||||
|
|
||||||
const fitTooltip = (): void => {
|
const fitTooltip = (tooltipHTMLToCheck: HTMLElement): void => {
|
||||||
if (($tooltip.label || $tooltip.component) && tooltipHTML) {
|
if (($tooltip.label || $tooltip.component) && tooltipHTML && tooltipHTMLToCheck) {
|
||||||
if ($tooltip.element) {
|
if ($tooltip.element) {
|
||||||
rect = $tooltip.element.getBoundingClientRect()
|
rect = $tooltip.element.getBoundingClientRect()
|
||||||
rectAnchor = $tooltip.anchor
|
rectAnchor = $tooltip.anchor
|
||||||
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
if ($tooltip.component) {
|
if ($tooltip.component) {
|
||||||
clearStyles()
|
clearStyles()
|
||||||
if (rect.bottom + tooltipHTML.clientHeight + 28 < docHeight) {
|
if (rect.bottom + tooltipHTMLToCheck.clientHeight + 28 < docHeight) {
|
||||||
tooltipHTML.style.top = `calc(${rect.bottom}px + 5px + .25rem)`
|
tooltipHTML.style.top = `calc(${rect.bottom}px + 5px + .25rem)`
|
||||||
dir = 'bottom'
|
dir = 'bottom'
|
||||||
} else if (rect.top > docHeight - rect.bottom) {
|
} else if (rect.top > docHeight - rect.bottom) {
|
||||||
@ -66,7 +66,7 @@
|
|||||||
dir = 'top'
|
dir = 'top'
|
||||||
} else {
|
} else {
|
||||||
tooltipHTML.style.top = `calc(${rect.bottom}px + 5px + .25rem)`
|
tooltipHTML.style.top = `calc(${rect.bottom}px + 5px + .25rem)`
|
||||||
if (tooltipHTML.clientHeight > docHeight - rect.bottom - 28) {
|
if (tooltipHTMLToCheck.clientHeight > docHeight - rect.bottom - 28) {
|
||||||
tooltipHTML.style.bottom = '1rem'
|
tooltipHTML.style.bottom = '1rem'
|
||||||
tooltipHTML.style.height = `calc(${docHeight - rect.bottom}px - 5px - 1.25rem)`
|
tooltipHTML.style.height = `calc(${docHeight - rect.bottom}px - 5px - 1.25rem)`
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@
|
|||||||
if (!$tooltip.direction) {
|
if (!$tooltip.direction) {
|
||||||
if (rectAnchor.right < docWidth / 5) dir = 'right'
|
if (rectAnchor.right < docWidth / 5) dir = 'right'
|
||||||
else if (rectAnchor.left > docWidth - docWidth / 5) dir = 'left'
|
else if (rectAnchor.left > docWidth - docWidth / 5) dir = 'left'
|
||||||
else if (rectAnchor.top < tooltipHTML.clientHeight) dir = 'bottom'
|
else if (rectAnchor.top < tooltipHTMLToCheck.clientHeight) dir = 'bottom'
|
||||||
else dir = 'top'
|
else dir = 'top'
|
||||||
} else dir = $tooltip.direction
|
} else dir = $tooltip.direction
|
||||||
|
|
||||||
@ -165,7 +165,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterUpdate(() => (kind === 'submenu' ? fitSubmenu() : fitTooltip()))
|
$: fitTooltip(tooltipHTML)
|
||||||
|
afterUpdate(() => (kind === 'submenu' ? fitSubmenu() : fitTooltip(tooltipHTML)))
|
||||||
onDestroy(() => hideTooltip())
|
onDestroy(() => hideTooltip())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user