@ngx-extensions/count-up.js
Version:
Wrapper module for countup.js
2 lines • 3.24 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/cdk/coercion"),require("countup.js")):"function"==typeof define&&define.amd?define("@ngx-extensions/count-up.js",["exports","@angular/core","@angular/cdk/coercion","countup.js"],e):e((t["ngx-extensions"]=t["ngx-extensions"]||{},t["ngx-extensions"]["count-up"]=t["ngx-extensions"]["count-up"]||{},t["ngx-extensions"]["count-up"].js={}),t.ng.core,t.ng.cdk.coercion,t.CountUp)}(this,function(t,e,n,r){"use strict";var i=function(){function o(t){this.elementRef=t,this.decimals=0,this.animationStarted=new e.EventEmitter,this.animationCompleted=new e.EventEmitter,this._startValue=0,this._endValue=0,this._duration=2,this._reanimateOnClick=!1}return Object.defineProperty(o.prototype,"endValue",{get:function(){return this._endValue},set:function(t){this._endValue=n.coerceNumberProperty(t),this.countUp&&this.countUp.update(this.endValue)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"reanimateOnClick",{get:function(){return this._reanimateOnClick},set:function(t){this._reanimateOnClick=n.coerceBooleanProperty(t)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"duration",{get:function(){return this._duration},set:function(t){this._duration=n.coerceNumberProperty(t)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"startValue",{get:function(){return this._startValue},set:function(t){this._startValue=n.coerceNumberProperty(t)},enumerable:!0,configurable:!0}),o.prototype.ngAfterViewInit=function(){this.countUp=this.createCountUp(),this.animate()},o.prototype.onClick=function(){this.reanimateOnClick&&this.animate()},o.prototype.animate=function(){var t=this;this.countUp.reset(),this.onAnimationStarted(),999<this.endValue?this.countUp.start(function(){return t.onAnimationCompleted(function(){return t.countUp.update(t.endValue)})}):this.countUp.start(function(){return t.onAnimationCompleted()})},o.prototype.createCountUp=function(){var t,n=this,e=function(t,e){return new r(n.elementRef.nativeElement,n.startValue,t,n.decimals,e,n.options)};if(999<Math.abs(this.endValue-this.startValue)){var i=this.endValue>this.startValue?-1:1;t=e(this.endValue+i*o.LARGE_VALUE_FIX,this.duration/2)}else t=e(this.endValue,this.duration);return t},o.prototype.onAnimationStarted=function(){this.animationStarted.emit()},o.prototype.onAnimationCompleted=function(t){this.animationCompleted.emit(),t&&t()},o.LARGE_VALUE_FIX=100,o.decorators=[{type:e.Directive,args:[{selector:"[ngxCountUp]",exportAs:"ngxCountUp"}]}],o.ctorParameters=function(){return[{type:e.ElementRef}]},o.propDecorators={options:[{type:e.Input,args:["ngxCountUp"]}],endValue:[{type:e.Input}],reanimateOnClick:[{type:e.Input}],duration:[{type:e.Input}],decimals:[{type:e.Input}],startValue:[{type:e.Input}],animationStarted:[{type:e.Output}],animationCompleted:[{type:e.Output}],onClick:[{type:e.HostListener,args:["click"]}]},o}(),o=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[i],exports:[i]}]}],t}();t.NgxCountUpDirective=i,t.NgxCountUpModule=o,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-extensions-count-up.js.umd.min.js.map