unicorn-components
Version:
<a target="_blank" href="https://getunicorn.io"><img src="https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2017/Jul/07/2615006260-5-nitsnetsstudios-ondemand-UNI_avatar.png" align="left"></a>
55 lines (43 loc) • 1.11 kB
text/typescript
import {
AfterContentInit,
Component,
ElementRef,
EventEmitter,
Output,
HostBinding,
} from '@angular/core';
export interface ToastOptions { showClose: boolean; }
({
selector: 'uni-toast',
templateUrl: 'toast.component.html',
styleUrls: ['toast.component.scss'],
})
export class UniToastComponent implements AfterContentInit {
('class.uni-toast') componentClass = true;
animateIn = false;
animateOut = false;
toastOptions: ToastOptions = null;
msg = '';
() accept = new EventEmitter();
constructor(private elementRef: ElementRef) { }
ngAfterContentInit() {
this.animateIn = false;
setTimeout(() => this.onEndAnimateOpen(), 50);
}
onEndAnimateOpen() {
this.animateIn = true;
}
initContent(options: ToastOptions) {
this.toastOptions = options;
}
setMessage(msg: string) {
this.msg = msg;
}
clickClose() {
this.accept.emit(true);
}
close() {
this.animateIn = false;
this.animateOut = true;
}
}