sync
This commit is contained in:
@ -66,15 +66,33 @@ function setTooltip(container, content, flag = false, parent = null) {
|
||||
}
|
||||
}
|
||||
p = c.parentElement;
|
||||
const offsetParent = c.offsetParent;
|
||||
while (p != null && p !== (isParent ? parent : offsetParent)) {
|
||||
const offsetParent = isParent ? parent : c.offsetParent;
|
||||
while (p != null && p !== offsetParent) {
|
||||
left -= p.scrollLeft;
|
||||
top -= p.scrollTop;
|
||||
p = p.parentElement;
|
||||
}
|
||||
left += (c.offsetWidth - wrapper.offsetWidth) / 2;
|
||||
top -= wrapper.offsetHeight + 14;
|
||||
wrapper.style.left = `${left}px`;
|
||||
// check overflow
|
||||
let t = c.offsetTop;
|
||||
p = c.offsetParent;
|
||||
while (p != null) {
|
||||
const overflow = window.getComputedStyle(p).overflow;
|
||||
if (overflow !== 'visible') {
|
||||
break;
|
||||
}
|
||||
t += p.offsetTop;
|
||||
p = p.offsetParent;
|
||||
}
|
||||
const offsetHeight = wrapper.offsetHeight + 14;
|
||||
if (t + top - offsetHeight < 0) {
|
||||
top += c.parentElement.offsetHeight + 14;
|
||||
wrapper.classList.add('ui-tooltip-down');
|
||||
} else {
|
||||
top -= offsetHeight;
|
||||
wrapper.classList.remove('ui-tooltip-down');
|
||||
}
|
||||
wrapper.style.top = `${top}px`;
|
||||
wrapper.style.visibility = 'visible';
|
||||
wrapper.style.opacity = 1;
|
||||
|
Reference in New Issue
Block a user