Skip to content

Commit

Permalink
added delay (v1.2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielFHcode committed Aug 25, 2022
1 parent 6276d68 commit f2e581a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions hoverer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ function applyHoverer(element,text){
'padding: 0.45em;'+
'font-family: sans-serif;'+
'font-size: 0.8em;'

document.body.appendChild(textElement);

let isMouseOver = false;
element.addEventListener('mouseover',function(e){
const elementTrans = getTextBoxTrans(element);
textElement.style.left = elementTrans.x+'px';
textElement.style.top = elementTrans.y+'px';
textElement.style.opacity = 1;
if (isMouseOver) return;
isMouseOver = true;
setTimeout(function(){
if (!isMouseOver) return;
const elementTrans = getTextBoxTrans(element);
textElement.style.left = elementTrans.x+'px';
textElement.style.top = elementTrans.y+'px';
textElement.style.opacity = 1;
},500)
})
element.addEventListener('mouseleave',function(){
isMouseOver = false;
textElement.style.opacity = 0;
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hoverer",
"version": "1.0.3",
"version": "1.2.0",
"description": "make text appear on hover",
"main": "hoverer.js",
"scripts": {},
Expand Down

0 comments on commit f2e581a

Please sign in to comment.