mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
feat: check if text is ellipsised before attaching tooltip
This commit is contained in:
committed by
Mungai Njoroge
parent
eb8c4e5628
commit
1c3998aa25
@@ -46,8 +46,21 @@ function hideTooltip() {
|
|||||||
tooltip.style.visibility = "hidden";
|
tooltip.style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
function getFullWidth(el: HTMLElement) {
|
||||||
mounted(el: HTMLElement, binding) {
|
// display el as inline-block to get the correct width
|
||||||
|
el.style.display = "inline-block";
|
||||||
|
el.style.visibility = "hidden";
|
||||||
|
document.getElementsByTagName("body")[0].appendChild(el);
|
||||||
|
const width = el.offsetWidth;
|
||||||
|
el.remove();
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (el: HTMLElement) => {
|
||||||
|
const fullWidth = getFullWidth(el.cloneNode(true) as HTMLElement);
|
||||||
|
if (fullWidth <= el.offsetWidth) return;
|
||||||
|
|
||||||
if (!tooltip) {
|
if (!tooltip) {
|
||||||
tooltip = getTooltip();
|
tooltip = getTooltip();
|
||||||
}
|
}
|
||||||
@@ -76,11 +89,13 @@ export default {
|
|||||||
hideTooltip();
|
hideTooltip();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
};
|
||||||
beforeUnmount(el: HTMLElement) {
|
|
||||||
hideTooltip();
|
|
||||||
|
|
||||||
el.removeEventListener("mouseover", () => {});
|
// } as Directive;
|
||||||
el.removeEventListener("mouseout", () => {});
|
|
||||||
},
|
// beforeUnmount(el: HTMLElement) {
|
||||||
} as Directive;
|
// // hideTooltip();
|
||||||
|
|
||||||
|
// el.removeEventListener("mouseover", () => {});
|
||||||
|
// el.removeEventListener("mouseout", () => {});
|
||||||
|
// },
|
||||||
|
|||||||
Reference in New Issue
Block a user