mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 12:03:03 +00:00
53881: facet search box
This commit is contained in:
20
src/app/shared/utils/click-outside.directive.ts
Normal file
20
src/app/shared/utils/click-outside.directive.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Directive, ElementRef, Output, EventEmitter, HostListener} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[dsClickOutside]'
|
||||
})
|
||||
export class ClickOutsideDirective {
|
||||
constructor(private _elementRef: ElementRef) {
|
||||
}
|
||||
|
||||
@Output()
|
||||
public dsClickOutside = new EventEmitter();
|
||||
|
||||
@HostListener('document:click', ['$event.target'])
|
||||
public onClick(targetElement) {
|
||||
const clickedInside = this._elementRef.nativeElement.contains(targetElement);
|
||||
if (!clickedInside) {
|
||||
this.dsClickOutside.emit(null);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user