add document, fix tooltip position issue
This commit is contained in:
@ -23,8 +23,16 @@ function setTooltip(container, content) {
|
||||
container.addEventListener('mouseenter', () => {
|
||||
tid && clearTimeout(tid);
|
||||
tid = setTimeout(() => {
|
||||
const left = container.offsetLeft + container.offsetWidth / 2 - wrapper.offsetWidth / 2;
|
||||
const top = container.offsetTop - wrapper.offsetHeight - 14;
|
||||
let left = container.offsetLeft;
|
||||
let top = container.offsetTop;
|
||||
let parent = container.parentElement;
|
||||
while (parent != null) {
|
||||
left -= parent.scrollLeft;
|
||||
top -= parent.scrollTop;
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
left -= wrapper.offsetWidth / 2 - container.offsetWidth / 2;
|
||||
top -= wrapper.offsetHeight + 14;
|
||||
wrapper.style.left = `${left}px`;
|
||||
wrapper.style.top = `${top}px`;
|
||||
wrapper.style.visibility = 'visible';
|
||||
|
Reference in New Issue
Block a user