angular-icon-morphing
Version:
Angular library to animate icons with smooth morphing animation
93 lines (84 loc) • 3.93 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('angular-icon-morphing', ['exports', '@angular/core'], factory) :
(global = global || self, factory(global['angular-icon-morphing'] = {}, global.ng.core));
}(this, (function (exports, i0) { 'use strict';
var AngularIconMorphingService = /** @class */ (function () {
function AngularIconMorphingService() {
}
return AngularIconMorphingService;
}());
AngularIconMorphingService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AngularIconMorphingService_Factory() { return new AngularIconMorphingService(); }, token: AngularIconMorphingService, providedIn: "root" });
AngularIconMorphingService.decorators = [
{ type: i0.Injectable, args: [{
providedIn: 'root'
},] }
];
AngularIconMorphingService.ctorParameters = function () { return []; };
var IconComponent = /** @class */ (function () {
function IconComponent() {
this.easing = 'linear';
this.duration = 250;
this.containerId = 'ic-' + Math.floor(Math.random() * 1000000);
}
IconComponent.prototype.ngOnInit = function () {
};
IconComponent.prototype.ngAfterContentInit = function () {
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' });
};
IconComponent.prototype.ngOnChanges = function (changes) {
if (changes.active) {
this.doTransition();
}
};
IconComponent.prototype.doTransition = function () {
if (this.svgMorpheus) {
var target = (!this.active) ? 'startIcon' : 'endIcon';
this.svgMorpheus.to(target, { duration: this.duration, easing: this.easing, rotation: 'none' }, null);
}
};
return IconComponent;
}());
IconComponent.decorators = [
{ type: i0.Component, args: [{
selector: 'aim-icon',
template: "<div #iconContainer>\r\n <ng-content></ng-content>\r\n</div>",
styles: [".hidden{display:none}"]
},] }
];
IconComponent.ctorParameters = function () { return []; };
IconComponent.propDecorators = {
startIcon: [{ type: i0.ContentChild, args: ['startIcon', { static: true },] }],
endIcon: [{ type: i0.ContentChild, args: ['endIcon', { static: true },] }],
iconContainer: [{ type: i0.ViewChild, args: ['iconContainer', { static: true },] }],
active: [{ type: i0.Input }],
easing: [{ type: i0.Input }],
duration: [{ type: i0.Input }]
};
var AngularIconMorphingModule = /** @class */ (function () {
function AngularIconMorphingModule() {
}
return AngularIconMorphingModule;
}());
AngularIconMorphingModule.decorators = [
{ type: i0.NgModule, args: [{
declarations: [IconComponent],
imports: [],
exports: [IconComponent]
},] }
];
/*
* Public API Surface of angular-icon-morphing
*/
/**
* Generated bundle index. Do not edit.
*/
exports.AngularIconMorphingModule = AngularIconMorphingModule;
exports.AngularIconMorphingService = AngularIconMorphingService;
exports.IconComponent = IconComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=angular-icon-morphing.umd.js.map