From 1e7697e9e36325f1453903713e9e1e0f4eaa642c Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Mon, 20 May 2024 15:32:47 +0200 Subject: [PATCH] fix: simplify tooltip --- .../src/lib/directives/tooltip.directive.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/projects/ngx-cream-lib/src/lib/directives/tooltip.directive.ts b/projects/ngx-cream-lib/src/lib/directives/tooltip.directive.ts index c041a76..69a70a8 100644 --- a/projects/ngx-cream-lib/src/lib/directives/tooltip.directive.ts +++ b/projects/ngx-cream-lib/src/lib/directives/tooltip.directive.ts @@ -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) { @@ -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(); } }