UNPKG

angular-icon-morphing

Version:

Angular library to animate icons with smooth morphing animation

77 lines (70 loc) 2.68 kB
import { ɵɵdefineInjectable, Injectable, Component, ContentChild, ViewChild, Input, NgModule } from '@angular/core'; class AngularIconMorphingService { constructor() { } } AngularIconMorphingService.ɵprov = ɵɵdefineInjectable({ factory: function AngularIconMorphingService_Factory() { return new AngularIconMorphingService(); }, token: AngularIconMorphingService, providedIn: "root" }); AngularIconMorphingService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; AngularIconMorphingService.ctorParameters = () => []; class IconComponent { constructor() { this.easing = 'linear'; this.duration = 250; this.containerId = 'ic-' + Math.floor(Math.random() * 1000000); } ngOnInit() { } ngAfterContentInit() { this.startIcon.nativeElement.id = 'startIcon'; this.endIcon.nativeElement.id = 'endIcon'; this.iconContainer.nativeElement.id = this.containerId; this.svgMorpheus = new SVGMorpheus('#' + this.containerId + ' svg', { iconId: 'startIcon' }); } ngOnChanges(changes) { if (changes.active) { this.doTransition(); } } doTransition() { if (this.svgMorpheus) { const target = (!this.active) ? 'startIcon' : 'endIcon'; this.svgMorpheus.to(target, { duration: this.duration, easing: this.easing, rotation: 'none' }, null); } } } IconComponent.decorators = [ { type: Component, args: [{ selector: 'aim-icon', template: "<div #iconContainer>\r\n <ng-content></ng-content>\r\n</div>", styles: [".hidden{display:none}"] },] } ]; IconComponent.ctorParameters = () => []; IconComponent.propDecorators = { startIcon: [{ type: ContentChild, args: ['startIcon', { static: true },] }], endIcon: [{ type: ContentChild, args: ['endIcon', { static: true },] }], iconContainer: [{ type: ViewChild, args: ['iconContainer', { static: true },] }], active: [{ type: Input }], easing: [{ type: Input }], duration: [{ type: Input }] }; class AngularIconMorphingModule { } AngularIconMorphingModule.decorators = [ { type: NgModule, args: [{ declarations: [IconComponent], imports: [], exports: [IconComponent] },] } ]; /* * Public API Surface of angular-icon-morphing */ /** * Generated bundle index. Do not edit. */ export { AngularIconMorphingModule, AngularIconMorphingService, IconComponent }; //# sourceMappingURL=angular-icon-morphing.js.map