From 77724600d1399a466a83c2e63681cf2dac0f40c6 Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Thu, 17 Oct 2019 11:29:18 +0200 Subject: [PATCH] #2 fixed --- css/ln.vue.css | 1 + js/ln.vue.components.js | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/css/ln.vue.css b/css/ln.vue.css index 15c64e8..a6048ac 100644 --- a/css/ln.vue.css +++ b/css/ln.vue.css @@ -65,6 +65,7 @@ div.ln-tooltip { } div.ln-tooltip[VISIBLE] { opacity: 1.0; + transition: opacity 300ms linear; } body { diff --git a/js/ln.vue.components.js b/js/ln.vue.components.js index 0b2bb8b..cc41a3d 100644 --- a/js/ln.vue.components.js +++ b/js/ln.vue.components.js @@ -18,21 +18,16 @@ function findTooltipData(el){ } function tooltipShow(ev,tooltip){ - if (tooltipEl.parentElement) + if (!document.body.contains(tooltipEl)) document.body.appendChild(tooltipEl); tooltipEl.innerText = tooltip.value; tooltipEl.setAttribute("VISIBLE",""); tootlipVisible = true; - } function tooltipHide(ev,tooltip){ tooltipEl.removeAttribute("VISIBLE"); - setTimeout(()=>{ - //document.body.removeChild(tooltipEl); - }, 600); - tootlipVisible = false; } @@ -40,19 +35,23 @@ function tooltipMouseOver(ev){ let tooltip = findTooltipData(ev.target); if (!tooltip) console.log(ev); - if (tooltip.timeout) - clearTimeout(tooltip.timeout); - if (tootlipVisible) - tooltipHide(ev,tooltip); - else - tooltip.timeout = setTimeout(() => { - tooltipShow(ev,tooltip); - }, tooltip.delay || 800); if (tooltipEl){ tooltipEl.style.left = `${ev.x+3}px`; tooltipEl.style.top = `${ev.y+3}px`; } + + if (tooltip.timeout) + clearTimeout(tooltip.timeout); + if (tootlipVisible){ + tooltip.timeout = setTimeout(() => { + tooltipHide(ev,tooltip); + }, (tooltip.delay ? (tooltip.delay / 4) : 200)); + } else { + tooltip.timeout = setTimeout(() => { + tooltipShow(ev,tooltip); + }, tooltip.delay || 800); + } } function tooltipMouseOut(ev){