Skip to content

Commit

Permalink
feat(tooltip): add custom trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Feb 5, 2019
1 parent c0571bf commit e980bd9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class Tooltip extends React.Component {
this.target?.addEventListener('click', this.toggleTooltip, false);
document.addEventListener('click', this.onClickOutside, false);
break;
case 'custom':
break;
default:
this.target?.addEventListener('mouseenter', this.openTooltip, false);
this.target?.addEventListener('mouseleave', this.closeTooltip, false);
this.target?.addEventListener('mouseenter', this.open, false);
this.target?.addEventListener('mouseleave', this.close, false);
break;
}
}
Expand All @@ -62,11 +64,11 @@ class Tooltip extends React.Component {
}
}

openTooltip = () => {
open = () => {
this.toggleTooltip(true);
}

closeTooltip = () => {
close = () => {
this.toggleTooltip(false);
}

Expand Down Expand Up @@ -183,9 +185,11 @@ class Tooltip extends React.Component {
this.target?.removeEventListener('click', this.toggleTooltip);
document.removeEventListener('click', this.onClickOutside);
break;
case 'custom':
break;
default:
this.target?.removeEventListener('mouseenter', this.openTooltip);
this.target?.removeEventListener('mouseleave', this.closeTooltip);
this.target?.removeEventListener('mouseenter', this.open);
this.target?.removeEventListener('mouseleave', this.close);
break;
}
}
Expand Down

0 comments on commit e980bd9

Please sign in to comment.