ngx-autohide
Version:
This library is used to automatically hide an Angular Component.
78 lines (72 loc) • 3.33 kB
JavaScript
import * as i1 from '@angular/animations';
import { style, animate } from '@angular/animations';
import * as i0 from '@angular/core';
import { Directive, Input, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
class NgxAutohideDirective {
constructor(el, builder) {
this.el = el;
this.builder = builder;
this.timings = DEFAULT_TIME;
}
ngOnInit() {
// based on a time to hide the element
const factory = this.builder.build(this.fadeOut());
const player = factory.create(this.el.nativeElement);
player.onDone(() => {
// after the animation is done, the element is removed
this.el.nativeElement.remove();
});
player.play();
}
/**
* This is the fadeOut function that set the fade out effect for the AnimationBuilder
* @returns returns an AnimationMetadata array
*/
fadeOut() {
return [
style({ opacity: '*' }),
animate(this.timings + 'ms ease-in', style({ opacity: 0 })),
];
}
}
NgxAutohideDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideDirective, deps: [{ token: i0.ElementRef }, { token: i1.AnimationBuilder }], target: i0.ɵɵFactoryTarget.Directive });
NgxAutohideDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.3", type: NgxAutohideDirective, selector: "[ngxAutohide]", inputs: { timings: "timings" }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngxAutohide]'
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.AnimationBuilder }]; }, propDecorators: { timings: [{
type: Input
}] } });
const DEFAULT_TIME = 5000;
class NgxAutohideModule {
}
NgxAutohideModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
NgxAutohideModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideModule, declarations: [NgxAutohideDirective], imports: [FormsModule], exports: [NgxAutohideDirective] });
NgxAutohideModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideModule, imports: [[
FormsModule,
]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: NgxAutohideModule, decorators: [{
type: NgModule,
args: [{
declarations: [
NgxAutohideDirective
],
imports: [
FormsModule,
],
exports: [
NgxAutohideDirective
]
}]
}] });
/*
* Public API Surface of ngx-autohide
*/
/**
* Generated bundle index. Do not edit.
*/
export { DEFAULT_TIME, NgxAutohideDirective, NgxAutohideModule };
//# sourceMappingURL=ngx-autohide.mjs.map