tooltip position issue (for tiny space)
This commit is contained in:
parent
2366b378d2
commit
99d4aa59a8
@ -56,4 +56,8 @@
|
||||
bottom: unset;
|
||||
top: -8px;
|
||||
}
|
||||
|
||||
&.ui-tooltip-no>.ui-tooltip-pointer {
|
||||
display: none;
|
||||
}
|
||||
}
|
@ -75,29 +75,53 @@ function setTooltip(container, content, flag = false, parent = null) {
|
||||
// check overflow
|
||||
let t = c.offsetTop;
|
||||
let l = c.offsetLeft;
|
||||
let lastWidth = c.offsetWidth;
|
||||
p = c.offsetParent;
|
||||
let lastWidth = p.clientWidth;
|
||||
let lastHeight = p.clientHeight;
|
||||
while (p != null) {
|
||||
const overflow = window.getComputedStyle(p).overflow;
|
||||
if (overflow !== 'visible') {
|
||||
t -= p.scrollTop;
|
||||
l -= p.scrollLeft;
|
||||
break;
|
||||
}
|
||||
t += p.offsetTop;
|
||||
l += p.offsetLeft;
|
||||
lastWidth = p.offsetWidth;
|
||||
p = p.offsetParent;
|
||||
const w = p.clientWidth;
|
||||
if (w < lastWidth) {
|
||||
lastWidth += l;
|
||||
} else {
|
||||
lastWidth = p.clientWidth;
|
||||
}
|
||||
const h = p.clientHeight;
|
||||
if (h < lastHeight) {
|
||||
lastHeight += t;
|
||||
} else {
|
||||
lastHeight = p.clientHeight;
|
||||
}
|
||||
const parent = p.offsetParent;
|
||||
while (p != null && p != parent) {
|
||||
t -= p.scrollTop;
|
||||
l -= p.scrollLeft;
|
||||
p = p.parentElement;
|
||||
}
|
||||
}
|
||||
const offsetHeight = wrapper.offsetHeight + 14;
|
||||
if (t + top - offsetHeight < 0) {
|
||||
top += c.parentElement.offsetHeight + 10;
|
||||
wrapper.classList.add('ui-tooltip-down');
|
||||
const offsetHeight = wrapper.offsetHeight;
|
||||
if (t - offsetHeight - 14 < 0) {
|
||||
if (t + offsetHeight + 2 > lastHeight) {
|
||||
top = lastHeight - offsetHeight + 2;
|
||||
wrapper.classList.add('ui-tooltip-no');
|
||||
} else {
|
||||
top += c.parentElement.offsetHeight + 10;
|
||||
wrapper.classList.add('ui-tooltip-down');
|
||||
}
|
||||
} else {
|
||||
top -= offsetHeight;
|
||||
top -= offsetHeight + 14;
|
||||
wrapper.classList.remove('ui-tooltip-down');
|
||||
}
|
||||
const offsetWidth = wrapper.offsetWidth;
|
||||
left += (c.offsetWidth - offsetWidth) / 2;
|
||||
if (left < -l) {
|
||||
if (l - offsetWidth < 0) {
|
||||
left = 2;
|
||||
} else if (left + offsetWidth + 2 > lastWidth) {
|
||||
left = lastWidth - offsetWidth - 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user