bia-framework
Version:
Bia Framework to work with angular 2
48 lines (37 loc) • 1.07 kB
text/typescript
/**
* Created by jd on 28/04/2016.
*/
import {Directive, Input, OnInit, Output, EventEmitter, OnDestroy, HostListener} from '@angular/core';
({
selector: 'core-document-mouseup'
})
export class CoreDocumentMouseUp implements OnInit, OnDestroy
{
() canHandler:boolean;
() handler = new EventEmitter<MouseEvent>();
//not propagate click event on host component
('mouseup', [ '$event' ])
private mouseup = ( $event ) =>
{
$event.stopPropagation();
};
constructor()
{
}
private iMouseUp = ( event:MouseEvent ):void =>
{
if (this.canHandler == null || this.canHandler == true)
this.handler.emit(event);
};
ngOnInit()
{
setTimeout(() =>
{
document.addEventListener('mouseup', this.iMouseUp);
}, 0);
}
ngOnDestroy()
{
document.removeEventListener('mouseup', this.iMouseUp);
}
}