sync
This commit is contained in:
@@ -4,7 +4,7 @@ import { global } from '../utility';
|
||||
|
||||
const pointerHeight = 12;
|
||||
|
||||
export function setTooltip(container, content, flag = false, parent = null) {
|
||||
export function setTooltip(container, content, flag = false, parent = null, maxLeft = null) {
|
||||
const isParent = parent instanceof HTMLElement;
|
||||
if (isParent) {
|
||||
const tipid = container.dataset.tipId;
|
||||
@@ -54,6 +54,7 @@ export function setTooltip(container, content, flag = false, parent = null) {
|
||||
return;
|
||||
}
|
||||
if (!flag || c.scrollWidth > c.offsetWidth) {
|
||||
wrapper.style.cssText += 'left: -9999px; top: -9999px; display: block';
|
||||
tid = setTimeout(() => {
|
||||
let p;
|
||||
let left;
|
||||
@@ -75,7 +76,6 @@ export function setTooltip(container, content, flag = false, parent = null) {
|
||||
top -= p.scrollTop;
|
||||
p = p.parentElement;
|
||||
}
|
||||
wrapper.style.display = '';
|
||||
const offsetHeight = wrapper.offsetHeight;
|
||||
const offsetWidth = wrapper.offsetWidth;
|
||||
if (isParent) {
|
||||
@@ -150,6 +150,15 @@ export function setTooltip(container, content, flag = false, parent = null) {
|
||||
left = lastWidth - offsetWidth - 1;
|
||||
}
|
||||
}
|
||||
if (typeof maxLeft === 'function') {
|
||||
const max = maxLeft(offsetWidth);
|
||||
if (left > max) {
|
||||
wrapper.style.setProperty('--pointer-left', 'calc(100% - 20px)');
|
||||
left = max;
|
||||
} else {
|
||||
wrapper.style.setProperty('--pointer-left', null);
|
||||
}
|
||||
}
|
||||
// wrapper.style.left = `${left}px`;
|
||||
// wrapper.style.top = `${top}px`;
|
||||
// wrapper.style.visibility = 'visible';
|
||||
|
||||
Reference in New Issue
Block a user