Skip to content

Commit

Permalink
add Hide when mouse leave
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinbcu01 authored and MrFrankel committed Mar 9, 2018
1 parent 6058106 commit 03f50ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/popper-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion src/popper-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class PopperController implements OnInit, OnChanges {
public static baseOptions: PopperContentOptions = <PopperContentOptions>{
placement: Placements.Auto,
hideOnClickOutside: true,
hideOnMouseLeave: false,
hideOnScroll: false,
showTrigger: Triggers.HOVER
};
Expand Down Expand Up @@ -81,6 +82,9 @@ export class PopperController implements OnInit, OnChanges {
@Input('popperHideOnScroll')
hideOnScroll: boolean | undefined;

@Input('popperHideOnMouseLeave')
hideOnMouseLeave: boolean | undefined;

@Input('popperPositionFixed')
positionFixed: boolean;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/popper.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface PopperContentOptions {
trigger?: Trigger;
positionFixed?: boolean;
hideOnClickOutside?: boolean;
hideOnMouseLeave?: boolean;
hideOnScroll?: boolean;
popperModifiers?: {};
}

0 comments on commit 03f50ed

Please sign in to comment.