contact tooltip issue

This commit is contained in:
2023-06-06 13:50:05 +08:00
parent 99d4aa59a8
commit c045aac4f9
3 changed files with 17 additions and 8 deletions

View File

@ -106,13 +106,15 @@ function setTooltip(container, content, flag = false, parent = null) {
p = p.parentElement;
}
}
wrapper.style.display = '';
const offsetHeight = wrapper.offsetHeight;
if (t - offsetHeight - 14 < 0) {
if (t + offsetHeight + 2 > lastHeight) {
top = lastHeight - offsetHeight + 2;
const parentOffsetHeight = c.parentElement.offsetHeight;
if (t + parentOffsetHeight + offsetHeight + 10 > lastHeight) {
top = lastHeight - offsetHeight - 2;
wrapper.classList.add('ui-tooltip-no');
} else {
top += c.parentElement.offsetHeight + 10;
top += parentOffsetHeight + 10;
wrapper.classList.add('ui-tooltip-down');
}
} else {
@ -126,10 +128,11 @@ function setTooltip(container, content, flag = false, parent = null) {
} else if (left + offsetWidth + 2 > lastWidth) {
left = lastWidth - offsetWidth - 2;
}
wrapper.style.left = `${left}px`;
wrapper.style.top = `${top}px`;
wrapper.style.visibility = 'visible';
wrapper.style.opacity = 1;
// wrapper.style.left = `${left}px`;
// wrapper.style.top = `${top}px`;
// wrapper.style.visibility = 'visible';
// wrapper.style.opacity = 1;
wrapper.style.cssText += `left: ${left}px; top: ${top}px; visibility: visible; opacity: 1`;
}, 100);
}
});
@ -138,6 +141,7 @@ function setTooltip(container, content, flag = false, parent = null) {
tid = setTimeout(() => {
wrapper.style.visibility = 'hidden';
wrapper.style.opacity = 0;
tid = setTimeout(() => wrapper.style.display = 'none', 120);
}, 300);
});
return container;