Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

countup.js

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

countup.js - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

6

demo.js

@@ -1,2 +0,2 @@

var countUpModule = require('./dist/countUp.js');
import { CountUp } from './dist/CountUp.js';

@@ -8,3 +8,3 @@ window.onload = function () {

var code, stars, endVal, options;
var demo = new countUpModule.CountUp('myTargetElement', 100);
var demo = new CountUp('myTargetElement', 100);
var codeVisualizer = document.getElementById('codeVisualizer');

@@ -111,3 +111,3 @@ var errorSection = document.getElementById('errorSection');

establishOptionsFromInputs();
demo = new countUpModule.CountUp('myTargetElement', endVal, options);
demo = new CountUp('myTargetElement', endVal, options);
if (!demo.error) {

@@ -114,0 +114,0 @@ errorSection.style.display = 'none';

@@ -1,2 +0,1 @@

"use strict";
var __assign = (this && this.__assign) || function () {

@@ -13,3 +12,2 @@ __assign = Object.assign || function(t) {

};
Object.defineProperty(exports, "__esModule", { value: true });
// playground: stackblitz.com/edit/countup-typescript

@@ -22,3 +20,3 @@ var CountUp = /** @class */ (function () {

this.options = options;
this.version = '2.0.3';
this.version = '2.0.4';
this.defaults = {

@@ -252,2 +250,2 @@ startVal: 0,

}());
exports.CountUp = CountUp;
export { CountUp };

@@ -1,1 +0,1 @@

"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,a=1,s=arguments.length;a<s;a++)for(var n in i=arguments[a])Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0});var CountUp=function(){function t(t,i,a){var h=this;this.target=t,this.endVal=i,this.options=a,this.version="2.0.3",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:""},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(t){h.startTime||(h.startTime=t);var i=t-h.startTime;h.remaining=h.duration-i,h.useEasing?h.countDown?h.frameVal=h.startVal-h.easingFn(i,0,h.startVal-h.endVal,h.duration):h.frameVal=h.easingFn(i,h.startVal,h.endVal-h.startVal,h.duration):h.countDown?h.frameVal=h.startVal-(h.startVal-h.endVal)*(i/h.duration):h.frameVal=h.startVal+(h.endVal-h.startVal)*(i/h.duration),h.countDown?h.frameVal=h.frameVal<h.endVal?h.endVal:h.frameVal:h.frameVal=h.frameVal>h.endVal?h.endVal:h.frameVal,h.frameVal=Math.round(h.frameVal*h.decimalMult)/h.decimalMult,h.printValue(h.frameVal),i<h.duration?h.rAF=requestAnimationFrame(h.count):null!==h.finalEndVal?h.update(h.finalEndVal):h.callback&&h.callback()},this.formatNumber=function(t){var i,a,s,n,e,r=t<0?"-":"";if(i=Math.abs(t).toFixed(h.options.decimalPlaces),s=(a=(i+="").split("."))[0],n=1<a.length?h.options.decimal+a[1]:"",h.options.useGrouping){e="";for(var o=0,l=s.length;o<l;++o)0!==o&&o%3==0&&(e=h.options.separator+e),e=s[l-o-1]+e;s=e}return h.options.numerals&&h.options.numerals.length&&(s=s.replace(/[0-9]/g,function(t){return h.options.numerals[+t]}),n=n.replace(/[0-9]/g,function(t){return h.options.numerals[+t]})),r+h.options.prefix+s+n+h.options.suffix},this.easeOutExpo=function(t,i,a,s){return a*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=__assign({},this.defaults,a),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(i),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.decimalMult=Math.pow(10,this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof t?document.getElementById(t):t,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined"}return t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold){this.finalEndVal=t;var a=this.countDown?1:-1;this.endVal=t+a*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.callback=t,0<this.duration?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i=this.formattingFn(t);"INPUT"===this.el.tagName?this.el.value=i:"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=i:this.el.innerHTML=i},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: "+t,null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();exports.CountUp=CountUp;
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,a=1,s=arguments.length;a<s;a++)for(var n in i=arguments[a])Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n]);return t}).apply(this,arguments)},CountUp=function(){function t(t,i,a){var s=this;this.target=t,this.endVal=i,this.options=a,this.version="2.0.4",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:""},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(t){s.startTime||(s.startTime=t);var i=t-s.startTime;s.remaining=s.duration-i,s.useEasing?s.countDown?s.frameVal=s.startVal-s.easingFn(i,0,s.startVal-s.endVal,s.duration):s.frameVal=s.easingFn(i,s.startVal,s.endVal-s.startVal,s.duration):s.countDown?s.frameVal=s.startVal-(s.startVal-s.endVal)*(i/s.duration):s.frameVal=s.startVal+(s.endVal-s.startVal)*(i/s.duration),s.countDown?s.frameVal=s.frameVal<s.endVal?s.endVal:s.frameVal:s.frameVal=s.frameVal>s.endVal?s.endVal:s.frameVal,s.frameVal=Math.round(s.frameVal*s.decimalMult)/s.decimalMult,s.printValue(s.frameVal),i<s.duration?s.rAF=requestAnimationFrame(s.count):null!==s.finalEndVal?s.update(s.finalEndVal):s.callback&&s.callback()},this.formatNumber=function(t){var i,a,n,e,r,o=t<0?"-":"";if(i=Math.abs(t).toFixed(s.options.decimalPlaces),n=(a=(i+="").split("."))[0],e=a.length>1?s.options.decimal+a[1]:"",s.options.useGrouping){r="";for(var l=0,h=n.length;l<h;++l)0!==l&&l%3==0&&(r=s.options.separator+r),r=n[h-l-1]+r;n=r}return s.options.numerals&&s.options.numerals.length&&(n=n.replace(/[0-9]/g,function(t){return s.options.numerals[+t]}),e=e.replace(/[0-9]/g,function(t){return s.options.numerals[+t]})),o+s.options.prefix+n+e+s.options.suffix},this.easeOutExpo=function(t,i,a,s){return a*(1-Math.pow(2,-10*t/s))*1024/1023+i},this.options=__assign({},this.defaults,a),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(i),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.decimalMult=Math.pow(10,this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof t?document.getElementById(t):t,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined"}return t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold){this.finalEndVal=t;var a=this.countDown?1:-1;this.endVal=t+a*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.callback=t,this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i=this.formattingFn(t);"INPUT"===this.el.tagName?this.el.value=i:"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=i:this.el.innerHTML=i},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: "+t,null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();export{CountUp};

@@ -1,1 +0,1 @@

!function(){for(var s=0,t=["webkit","moz","ms","o"],i=0;i<t.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[t[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[t[i]+"CancelAnimationFrame"]||window[t[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t){var i=(new Date).getTime(),a=Math.max(0,16-(i-s)),n=window.setTimeout(function(){return t(i+a)},a);return s=i+a,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}();var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,a=1,n=arguments.length;a<n;a++)for(var s in i=arguments[a])Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0});var CountUp=function(){function t(t,i,a){var u=this;this.target=t,this.endVal=i,this.options=a,this.version="2.0.3",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:""},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(t){u.startTime||(u.startTime=t);var i=t-u.startTime;u.remaining=u.duration-i,u.useEasing?u.countDown?u.frameVal=u.startVal-u.easingFn(i,0,u.startVal-u.endVal,u.duration):u.frameVal=u.easingFn(i,u.startVal,u.endVal-u.startVal,u.duration):u.countDown?u.frameVal=u.startVal-(u.startVal-u.endVal)*(i/u.duration):u.frameVal=u.startVal+(u.endVal-u.startVal)*(i/u.duration),u.countDown?u.frameVal=u.frameVal<u.endVal?u.endVal:u.frameVal:u.frameVal=u.frameVal>u.endVal?u.endVal:u.frameVal,u.frameVal=Math.round(u.frameVal*u.decimalMult)/u.decimalMult,u.printValue(u.frameVal),i<u.duration?u.rAF=requestAnimationFrame(u.count):null!==u.finalEndVal?u.update(u.finalEndVal):u.callback&&u.callback()},this.formatNumber=function(t){var i,a,n,s,e,r=t<0?"-":"";if(i=Math.abs(t).toFixed(u.options.decimalPlaces),n=(a=(i+="").split("."))[0],s=1<a.length?u.options.decimal+a[1]:"",u.options.useGrouping){e="";for(var o=0,l=n.length;o<l;++o)0!==o&&o%3==0&&(e=u.options.separator+e),e=n[l-o-1]+e;n=e}return u.options.numerals&&u.options.numerals.length&&(n=n.replace(/[0-9]/g,function(t){return u.options.numerals[+t]}),s=s.replace(/[0-9]/g,function(t){return u.options.numerals[+t]})),r+u.options.prefix+n+s+u.options.suffix},this.easeOutExpo=function(t,i,a,n){return a*(1-Math.pow(2,-10*t/n))*1024/1023+i},this.options=__assign({},this.defaults,a),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(i),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.decimalMult=Math.pow(10,this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof t?document.getElementById(t):t,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined"}return t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold){this.finalEndVal=t;var a=this.countDown?1:-1;this.endVal=t+a*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.callback=t,0<this.duration?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i=this.formattingFn(t);"INPUT"===this.el.tagName?this.el.value=i:"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=i:this.el.innerHTML=i},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: "+t,null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();exports.CountUp=CountUp;
!function(){for(var t=0,i=["webkit","moz","ms","o"],a=0;a<i.length&&!window.requestAnimationFrame;++a)window.requestAnimationFrame=window[i[a]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[a]+"CancelAnimationFrame"]||window[i[a]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(i){var a=(new Date).getTime(),n=Math.max(0,16-(a-t)),s=window.setTimeout(function(){return i(a+n)},n);return t=a+n,s}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}();var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,a=1,n=arguments.length;a<n;a++)for(var s in i=arguments[a])Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s]);return t}).apply(this,arguments)},CountUp=function(){function t(t,i,a){var n=this;this.target=t,this.endVal=i,this.options=a,this.version="2.0.4",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:""},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(t){n.startTime||(n.startTime=t);var i=t-n.startTime;n.remaining=n.duration-i,n.useEasing?n.countDown?n.frameVal=n.startVal-n.easingFn(i,0,n.startVal-n.endVal,n.duration):n.frameVal=n.easingFn(i,n.startVal,n.endVal-n.startVal,n.duration):n.countDown?n.frameVal=n.startVal-(n.startVal-n.endVal)*(i/n.duration):n.frameVal=n.startVal+(n.endVal-n.startVal)*(i/n.duration),n.countDown?n.frameVal=n.frameVal<n.endVal?n.endVal:n.frameVal:n.frameVal=n.frameVal>n.endVal?n.endVal:n.frameVal,n.frameVal=Math.round(n.frameVal*n.decimalMult)/n.decimalMult,n.printValue(n.frameVal),i<n.duration?n.rAF=requestAnimationFrame(n.count):null!==n.finalEndVal?n.update(n.finalEndVal):n.callback&&n.callback()},this.formatNumber=function(t){var i,a,s,e,r,o=t<0?"-":"";if(i=Math.abs(t).toFixed(n.options.decimalPlaces),s=(a=(i+="").split("."))[0],e=a.length>1?n.options.decimal+a[1]:"",n.options.useGrouping){r="";for(var l=0,u=s.length;l<u;++l)0!==l&&l%3==0&&(r=n.options.separator+r),r=s[u-l-1]+r;s=r}return n.options.numerals&&n.options.numerals.length&&(s=s.replace(/[0-9]/g,function(t){return n.options.numerals[+t]}),e=e.replace(/[0-9]/g,function(t){return n.options.numerals[+t]})),o+n.options.prefix+s+e+n.options.suffix},this.easeOutExpo=function(t,i,a,n){return a*(1-Math.pow(2,-10*t/n))*1024/1023+i},this.options=__assign({},this.defaults,a),this.formattingFn=this.options.formattingFn?this.options.formattingFn:this.formatNumber,this.easingFn=this.options.easingFn?this.options.easingFn:this.easeOutExpo,this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.endVal=this.validateValue(i),this.options.decimalPlaces=Math.max(this.options.decimalPlaces),this.decimalMult=Math.pow(10,this.options.decimalPlaces),this.resetDuration(),this.options.separator=String(this.options.separator),this.useEasing=this.options.useEasing,""===this.options.separator&&(this.options.useGrouping=!1),this.el="string"==typeof t?document.getElementById(t):t,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined"}return t.prototype.determineDirectionAndSmartEasing=function(){var t=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>t;var i=t-this.startVal;if(Math.abs(i)>this.options.smartEasingThreshold){this.finalEndVal=t;var a=this.countDown?1:-1;this.endVal=t+a*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=t,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},t.prototype.start=function(t){this.error||(this.callback=t,this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},t.prototype.pauseResume=function(){this.paused?(this.startTime=null,this.duration=this.remaining,this.startVal=this.frameVal,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count)):cancelAnimationFrame(this.rAF),this.paused=!this.paused},t.prototype.reset=function(){cancelAnimationFrame(this.rAF),this.paused=!0,this.resetDuration(),this.startVal=this.validateValue(this.options.startVal),this.frameVal=this.startVal,this.printValue(this.startVal)},t.prototype.update=function(t){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(t),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},t.prototype.printValue=function(t){var i=this.formattingFn(t);"INPUT"===this.el.tagName?this.el.value=i:"text"===this.el.tagName||"tspan"===this.el.tagName?this.el.textContent=i:this.el.innerHTML=i},t.prototype.ensureNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.prototype.validateValue=function(t){var i=Number(t);return this.ensureNumber(i)?i:(this.error="[CountUp] invalid start or end value: "+t,null)},t.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},t}();export{CountUp};
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const uglifyES = require('uglify-es');
const composer = require('gulp-uglify/composer');
const concat = require('gulp-concat');
const del = require('del');
const uglify = composer(uglifyES, console);

@@ -6,0 +8,0 @@ const clean = () => del(['dist/*']);

{
"name": "countup.js",
"description": "Animates a numerical value by counting to it",
"version": "2.0.3",
"version": "2.0.4",
"license": "MIT",
"main": "./dist/countUp.min.js",
"author": "@inorganik",
"main": "./dist/countUp.min.js",
"author": "@inorganik",
"repository": {

@@ -13,8 +13,8 @@ "type": "git",

"scripts": {
"build": "npm run clean && tsc && gulp",
"build:demo": "browserify demo.js -o ./dist/demo-bundle.js -u './dist/countUp'",
"build": "npm run clean && tsc && gulp",
"clean": "gulp clean",
"lint": "tslint --project tsconfig.json",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"serve": "http-server ./"
},

@@ -28,9 +28,11 @@ "dependencies": {},

"gulp-concat": "^2.6.1",
"gulp-uglify": "^3.0.1",
"gulp-uglify": "^3.0.2",
"http-server": "^0.11.1",
"jest": "^24.1.0",
"ts-jest": "^24.0.0",
"tslint": "^5.12.1",
"typescript": "^3.3.3"
"typescript": "^3.3.3",
"uglify-es": "^3.3.9"
},
"types": "./dist/countUp.d.ts"
}

@@ -10,2 +10,4 @@ # CountUp.js

---
## New in 2.0

@@ -19,3 +21,3 @@

CountUp is now distributed as a `commonjs` module - [see below](#including) for how to include it in your project.
CountUp is now distributed as a ES6 module - [see below](#including) for how to include it in your project.

@@ -31,2 +33,4 @@ ## See Also

---
## Usage:

@@ -107,21 +111,26 @@

```
---
## Including CountUp <a name="including"></a>
CountUp v2 is distributed as a `commonjs` module which means you need to include CountUp in your project using a build tool such as [Webpack](https://webpack.js.org/) or [Browserify](http://browserify.org/).
CountUp v2 is distributed as an ES6 module because it is the most standardized and most widely compatible module for browsers. For compatibility with IE and older versions of Firefox (< 60), if you are not using a build tool, you will need a [module loader polyfill](https://github.com/ModuleLoader/browser-es-module-loader). You can read more about ES6 modules, using the module polyfill and more [here](https://www.sitepoint.com/using-es-modules/). If you are interested in a different module wrapping, you could install a previous release because I've experimented with many of them. The CountUp code is the same; the module wrappings were changed.
**Example using Browserify**
- UMD - `npm i countup.js@2.0.0`.
- AMD - `npm i countup.js@2.0.1`.
- commonjs - `npm i countup@2.0.3`.
Install browserify and countup
For the examples below, first install CountUp. This will give you the latest:
```
npm i countup.js
npm i -g browserify
```
### Example with vanilla js
This is what I used in the demo. Checkout index.html and demo.js.
main.js:
```js
var countUpModule = require('countup.js');
import { CountUp } from './js/CountUp.min.js';
window.onload = function() {
var countUp = countUpModule.CountUp('target', 2000);
var countUp = new CountUp('target', 2000);
countUp.start();

@@ -131,13 +140,26 @@ }

Build your bundle
Include in your html. Notice the `type` attribute:
```
browserify main.js -o bundle.js
<script src="./js/countUp.min.js" type="module"></script>
<script src="./main.js" type="module"></script>
```
🎉 Done! Keep in mind to run locally you'll need a simple local server setup like [this](https://www.npmjs.com/package/http-server) (test the demo locally by running `npm run serve`) because otherwise you may see a CORS error when your browser tries to load the script as a module.
Include in your html:
### Example with Webpack
main.js:
```js
import { CountUp } from 'countup.js';
window.onload = function () {
var countUp = new CountUp('countup', 2000);
countUp.start();
}
```
<script src="bundle.js"></script>
```
🎉 Done!
_If you have included CountUp in another type of project and want to help the community, please add it to the README and make a PR._
---
## Contributing <a name="contributing"></a>

@@ -150,2 +172,2 @@

1. Run `npm run build`, which copies and minifies the .js files to the `dist` folder.
1. Test the demo: run `npm run build:demo` then open index.html in a browser and make sure it works.
1. Serve the demo by running `npm run serve` and visit http://localhost:8080 to make sure it counts.

@@ -22,3 +22,3 @@ export interface CountUpOptions { // (default)

version = '2.0.3';
version = '2.0.4';
private defaults: CountUpOptions = {

@@ -25,0 +25,0 @@ startVal: 0,

{
"compilerOptions": {
"lib": ["es2017", "dom"],
"module": "commonjs",
"module": "esnext",
"declaration": true,
"outDir": "dist",
"target": "es5",
"pretty": true
"pretty": true,
"esModuleInterop": true
},

@@ -10,0 +11,0 @@ "compileOnSave": true,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc