aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Tooltip/tooltip.ts23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/lib/Tooltip/tooltip.ts b/src/lib/Tooltip/tooltip.ts
index f01b8d64..c4725d93 100644
--- a/src/lib/Tooltip/tooltip.ts
+++ b/src/lib/Tooltip/tooltip.ts
@@ -2,7 +2,6 @@ const tooltip = (element: HTMLElement) => {
let div: HTMLDivElement;
let title: string | null;
const offset = 10;
- let timer: number;
const above = element.getAttribute('data-tooltip-above') !== null;
const mouseEnter = (event: MouseEvent) => {
@@ -10,21 +9,19 @@ const tooltip = (element: HTMLElement) => {
element.removeAttribute('title');
- timer = window.setTimeout(() => {
- div = document.createElement('div');
- div.textContent = title;
+ div = document.createElement('div');
+ div.textContent = title;
- div.setAttribute(
- 'style',
- `position: absolute;
+ div.setAttribute(
+ 'style',
+ `position: absolute;
top: -${event.pageX - div.offsetWidth / 2}px;
left: -${event.pageY - div.offsetHeight - offset / 2}px;`
- );
+ );
- div.classList.add('card');
- div.classList.add('card-small');
- document.body.appendChild(div);
- }, 0);
+ div.classList.add('card');
+ div.classList.add('card-small');
+ document.body.appendChild(div);
};
const mouseMove = (event: MouseEvent) => {
@@ -41,8 +38,6 @@ const tooltip = (element: HTMLElement) => {
};
const mouseLeave = () => {
- clearTimeout(timer);
-
if (div) {
document.body.removeChild(div);
element.setAttribute('title', title as string);