From 03f50ed313f94514650f75c75c82189b497d03be Mon Sep 17 00:00:00 2001 From: Agustin Barrios Date: Fri, 9 Mar 2018 08:27:05 -0600 Subject: [PATCH] add Hide when mouse leave --- src/popper-content.ts | 2 +- src/popper-directive.ts | 7 ++++++- src/popper.model.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/popper-content.ts b/src/popper-content.ts index 551448e..f3baae3 100644 --- a/src/popper-content.ts +++ b/src/popper-content.ts @@ -172,7 +172,7 @@ export class PopperContent implements OnDestroy { @HostListener('mouseleave') showOnLeave() { this.isMouseOver = false; - if (this.popperOptions.trigger !== Triggers.HOVER) { + if (this.popperOptions.trigger !== Triggers.HOVER && !this.popperOptions.hideOnMouseLeave) { return; } this.hide(); diff --git a/src/popper-directive.ts b/src/popper-directive.ts index b161989..575faab 100644 --- a/src/popper-directive.ts +++ b/src/popper-directive.ts @@ -38,6 +38,7 @@ export class PopperController implements OnInit, OnChanges { public static baseOptions: PopperContentOptions = { placement: Placements.Auto, hideOnClickOutside: true, + hideOnMouseLeave: false, hideOnScroll: false, showTrigger: Triggers.HOVER }; @@ -81,6 +82,9 @@ export class PopperController implements OnInit, OnChanges { @Input('popperHideOnScroll') hideOnScroll: boolean | undefined; + @Input('popperHideOnMouseLeave') + hideOnMouseLeave: boolean | undefined; + @Input('popperPositionFixed') positionFixed: boolean; @@ -146,7 +150,7 @@ export class PopperController implements OnInit, OnChanges { @HostListener('touchcancel') @HostListener('mouseleave') hideOnLeave(): void { - if (this.disabled || this.showTrigger !== Triggers.HOVER) { + if (this.disabled || (this.showTrigger !== Triggers.HOVER && !this.hideOnMouseLeave)) { return; } this.scheduledHide(null, this.hideTimeout); @@ -277,6 +281,7 @@ export class PopperController implements OnInit, OnChanges { this.showTrigger = typeof this.showTrigger === 'undefined' ? PopperController.baseOptions.trigger : this.showTrigger; this.hideOnClickOutside = typeof this.hideOnClickOutside === 'undefined' ? PopperController.baseOptions.hideOnClickOutside : this.hideOnClickOutside; this.hideOnScroll = typeof this.hideOnScroll === 'undefined' ? PopperController.baseOptions.hideOnScroll : this.hideOnScroll; + this.hideOnMouseLeave = typeof this.hideOnMouseLeave === 'undefined' ? PopperController.baseOptions.hideOnMouseLeave : this.hideOnMouseLeave; } private clearEventListeners() { diff --git a/src/popper.model.ts b/src/popper.model.ts index e4073e0..20d66de 100644 --- a/src/popper.model.ts +++ b/src/popper.model.ts @@ -59,6 +59,7 @@ export interface PopperContentOptions { trigger?: Trigger; positionFixed?: boolean; hideOnClickOutside?: boolean; + hideOnMouseLeave?: boolean; hideOnScroll?: boolean; popperModifiers?: {}; } \ No newline at end of file