Skip to content

Commit

Permalink
fix: simplify tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed May 20, 2024
1 parent 5ce4cfb commit 1e7697e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions projects/ngx-cream-lib/src/lib/directives/tooltip.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ export class TooltipDirective {
const elLeft = el.getBoundingClientRect().left;
const windowLeft = window.innerWidth;

if (elLeft + 250 > windowLeft) {
return true;
} else {
return false;
}
return elLeft + 250 > windowLeft;
}

storeOriginalPosition(el: any) {
Expand Down Expand Up @@ -67,36 +63,37 @@ export class TooltipDirective {
// Mouse and keyboard events
@HostListener('mouseenter', ['$event'])
handleMouseEnter(event: MouseEvent) {
this.openTooltip();
event.stopPropagation();
this.openTooltip();
}

@HostListener('focus', ['$event'])
handleFocus(event: MouseEvent) {
this.openTooltip();
event.stopPropagation();
this.openTooltip();
}

@HostListener('mouseleave', ['$event'])
handleMouseLeave(event: MouseEvent) {
this.closeAllTooltips();
event.stopPropagation();
this.closeAllTooltips();
}

@HostListener('mousedown', ['$event'])
handleMouseDown(event: MouseEvent) {
this.closeAllTooltips();
event.stopPropagation();
this.closeAllTooltips();
}

@HostListener('focusout', ['$event'])
handleFocusOut(event: MouseEvent) {
this.closeAllTooltips();
event.stopPropagation();
this.closeAllTooltips();
}

@HostListener('click', ['$event'])
handleClick(event: any) {
event.stopPropagation();
this.closeAllTooltips();
}
}

0 comments on commit 1e7697e

Please sign in to comment.