vue-countup-v3
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
# [1.2.0](https://github.com/jizai1125/vue-countup-v3/compare/v1.1.0...v1.2.0) (2023-05-25) | ||
# [1.1.0](https://github.com/jizai1125/vue-countup-v3/compare/v1.0.14...v1.1.0) (2022-11-18) | ||
@@ -2,0 +6,0 @@ |
@@ -30,3 +30,3 @@ export type { CountUp as ICountUp, CountUpOptions } from 'countup.js'; | ||
loop: { | ||
type: import("vue").PropType<string | number | boolean>; | ||
type: import("vue").PropType<number | boolean>; | ||
} & { | ||
@@ -75,3 +75,3 @@ default: boolean; | ||
loop: { | ||
type: import("vue").PropType<string | number | boolean>; | ||
type: import("vue").PropType<number | boolean>; | ||
} & { | ||
@@ -97,3 +97,3 @@ default: boolean; | ||
autoplay: boolean; | ||
loop: string | number | boolean; | ||
loop: number | boolean; | ||
startVal: string | number; | ||
@@ -100,0 +100,0 @@ decimalPlaces: number; |
@@ -21,78 +21,88 @@ var __defProp = Object.defineProperty; | ||
import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, renderSlot, createElementVNode } from "vue"; | ||
var __assign = globalThis && globalThis.__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(t2, i, a) { | ||
var n = this; | ||
this.endVal = i, this.options = a, this.version = "2.1.0", this.defaults = { startVal: 0, decimalPlaces: 0, duration: 2, useEasing: true, useGrouping: true, smartEasingThreshold: 999, smartEasingAmount: 333, separator: ",", decimal: ".", prefix: "", suffix: "", enableScrollSpy: false, scrollSpyDelay: 200 }, this.finalEndVal = null, this.useEasing = true, this.countDown = false, this.error = "", this.startVal = 0, this.paused = true, this.count = function(t3) { | ||
n.startTime || (n.startTime = t3); | ||
var i2 = t3 - n.startTime; | ||
n.remaining = n.duration - i2, n.useEasing ? n.countDown ? n.frameVal = n.startVal - n.easingFn(i2, 0, n.startVal - n.endVal, n.duration) : n.frameVal = n.easingFn(i2, n.startVal, n.endVal - n.startVal, n.duration) : n.countDown ? n.frameVal = n.startVal - (n.startVal - n.endVal) * (i2 / n.duration) : n.frameVal = n.startVal + (n.endVal - n.startVal) * (i2 / 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 = Number(n.frameVal.toFixed(n.options.decimalPlaces)), n.printValue(n.frameVal), i2 < n.duration ? n.rAF = requestAnimationFrame(n.count) : n.finalEndVal !== null ? n.update(n.finalEndVal) : n.callback && n.callback(); | ||
}, this.formatNumber = function(t3) { | ||
var i2, a2, s, e, r = t3 < 0 ? "-" : ""; | ||
i2 = Math.abs(t3).toFixed(n.options.decimalPlaces); | ||
var o = (i2 += "").split("."); | ||
if (a2 = o[0], s = o.length > 1 ? n.options.decimal + o[1] : "", n.options.useGrouping) { | ||
var t = function() { | ||
return t = Object.assign || function(t2) { | ||
for (var i2, n = 1, s = arguments.length; n < s; n++) | ||
for (var a in i2 = arguments[n]) | ||
Object.prototype.hasOwnProperty.call(i2, a) && (t2[a] = i2[a]); | ||
return t2; | ||
}, t.apply(this, arguments); | ||
}, i = function() { | ||
function i2(i3, n, s) { | ||
var a = this; | ||
this.endVal = n, this.options = s, this.version = "2.6.2", this.defaults = { startVal: 0, decimalPlaces: 0, duration: 2, useEasing: true, useGrouping: true, useIndianSeparators: false, smartEasingThreshold: 999, smartEasingAmount: 333, separator: ",", decimal: ".", prefix: "", suffix: "", enableScrollSpy: false, scrollSpyDelay: 200, scrollSpyOnce: false }, this.finalEndVal = null, this.useEasing = true, this.countDown = false, this.error = "", this.startVal = 0, this.paused = true, this.once = false, this.count = function(t2) { | ||
a.startTime || (a.startTime = t2); | ||
var i4 = t2 - a.startTime; | ||
a.remaining = a.duration - i4, a.useEasing ? a.countDown ? a.frameVal = a.startVal - a.easingFn(i4, 0, a.startVal - a.endVal, a.duration) : a.frameVal = a.easingFn(i4, a.startVal, a.endVal - a.startVal, a.duration) : a.frameVal = a.startVal + (a.endVal - a.startVal) * (i4 / a.duration); | ||
var n2 = a.countDown ? a.frameVal < a.endVal : a.frameVal > a.endVal; | ||
a.frameVal = n2 ? a.endVal : a.frameVal, a.frameVal = Number(a.frameVal.toFixed(a.options.decimalPlaces)), a.printValue(a.frameVal), i4 < a.duration ? a.rAF = requestAnimationFrame(a.count) : a.finalEndVal !== null ? a.update(a.finalEndVal) : a.options.onCompleteCallback && a.options.onCompleteCallback(); | ||
}, this.formatNumber = function(t2) { | ||
var i4, n2, s2, e, o = t2 < 0 ? "-" : ""; | ||
i4 = Math.abs(t2).toFixed(a.options.decimalPlaces); | ||
var r = (i4 += "").split("."); | ||
if (n2 = r[0], s2 = r.length > 1 ? a.options.decimal + r[1] : "", a.options.useGrouping) { | ||
e = ""; | ||
for (var l = 0, h = a2.length; l < h; ++l) | ||
l !== 0 && l % 3 == 0 && (e = n.options.separator + e), e = a2[h - l - 1] + e; | ||
a2 = e; | ||
for (var l = 3, h = 0, u = 0, p = n2.length; u < p; ++u) | ||
a.options.useIndianSeparators && u === 4 && (l = 2, h = 1), u !== 0 && h % l == 0 && (e = a.options.separator + e), h++, e = n2[p - u - 1] + e; | ||
n2 = e; | ||
} | ||
return n.options.numerals && n.options.numerals.length && (a2 = a2.replace(/[0-9]/g, function(t4) { | ||
return n.options.numerals[+t4]; | ||
}), s = s.replace(/[0-9]/g, function(t4) { | ||
return n.options.numerals[+t4]; | ||
})), r + n.options.prefix + a2 + s + n.options.suffix; | ||
}, this.easeOutExpo = function(t3, i2, a2, n2) { | ||
return a2 * (1 - Math.pow(2, -10 * t3 / n2)) * 1024 / 1023 + i2; | ||
}, this.options = __assign(__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.resetDuration(), this.options.separator = String(this.options.separator), this.useEasing = this.options.useEasing, this.options.separator === "" && (this.options.useGrouping = false), this.el = typeof t2 == "string" ? document.getElementById(t2) : t2, this.el ? this.printValue(this.startVal) : this.error = "[CountUp] target is null or undefined", window !== void 0 && this.options.enableScrollSpy && (this.error ? console.error(this.error, t2) : (window.onScrollFns = window.onScrollFns || [], window.onScrollFns.push(function() { | ||
return n.handleScroll(n); | ||
return a.options.numerals && a.options.numerals.length && (n2 = n2.replace(/[0-9]/g, function(t3) { | ||
return a.options.numerals[+t3]; | ||
}), s2 = s2.replace(/[0-9]/g, function(t3) { | ||
return a.options.numerals[+t3]; | ||
})), o + a.options.prefix + n2 + s2 + a.options.suffix; | ||
}, this.easeOutExpo = function(t2, i4, n2, s2) { | ||
return n2 * (1 - Math.pow(2, -10 * t2 / s2)) * 1024 / 1023 + i4; | ||
}, this.options = t(t({}, this.defaults), s), 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(n), this.options.decimalPlaces = Math.max(this.options.decimalPlaces), this.resetDuration(), this.options.separator = String(this.options.separator), this.useEasing = this.options.useEasing, this.options.separator === "" && (this.options.useGrouping = false), this.el = typeof i3 == "string" ? document.getElementById(i3) : i3, this.el ? this.printValue(this.startVal) : this.error = "[CountUp] target is null or undefined", typeof window != "undefined" && this.options.enableScrollSpy && (this.error ? console.error(this.error, i3) : (window.onScrollFns = window.onScrollFns || [], window.onScrollFns.push(function() { | ||
return a.handleScroll(a); | ||
}), window.onscroll = function() { | ||
window.onScrollFns.forEach(function(t3) { | ||
return t3(); | ||
window.onScrollFns.forEach(function(t2) { | ||
return t2(); | ||
}); | ||
}, this.handleScroll(this))); | ||
} | ||
return t.prototype.handleScroll = function(t2) { | ||
if (t2 && window) { | ||
var i = window.innerHeight + window.scrollY, a = t2.el.offsetTop + t2.el.offsetHeight; | ||
a < i && a > window.scrollY && t2.paused ? (t2.paused = false, setTimeout(function() { | ||
return i2.prototype.handleScroll = function(t2) { | ||
if (t2 && window && !t2.once) { | ||
var i3 = window.innerHeight + window.scrollY, n = t2.el.getBoundingClientRect(), s = n.top + window.pageYOffset, a = n.top + n.height + window.pageYOffset; | ||
a < i3 && a > window.scrollY && t2.paused ? (t2.paused = false, setTimeout(function() { | ||
return t2.start(); | ||
}, t2.options.scrollSpyDelay)) : window.scrollY > a && !t2.paused && t2.reset(); | ||
}, t2.options.scrollSpyDelay), t2.options.scrollSpyOnce && (t2.once = true)) : (window.scrollY > a || s > i3) && !t2.paused && t2.reset(); | ||
} | ||
}, t.prototype.determineDirectionAndSmartEasing = function() { | ||
}, i2.prototype.determineDirectionAndSmartEasing = function() { | ||
var t2 = this.finalEndVal ? this.finalEndVal : this.endVal; | ||
this.countDown = this.startVal > t2; | ||
var i = t2 - this.startVal; | ||
if (Math.abs(i) > this.options.smartEasingThreshold) { | ||
var i3 = t2 - this.startVal; | ||
if (Math.abs(i3) > this.options.smartEasingThreshold && this.options.useEasing) { | ||
this.finalEndVal = t2; | ||
var a = this.countDown ? 1 : -1; | ||
this.endVal = t2 + a * this.options.smartEasingAmount, this.duration = this.duration / 2; | ||
var n = this.countDown ? 1 : -1; | ||
this.endVal = t2 + n * this.options.smartEasingAmount, this.duration = this.duration / 2; | ||
} else | ||
this.endVal = t2, this.finalEndVal = null; | ||
this.finalEndVal ? this.useEasing = false : this.useEasing = this.options.useEasing; | ||
}, t.prototype.start = function(t2) { | ||
this.error || (this.callback = t2, this.duration > 0 ? (this.determineDirectionAndSmartEasing(), this.paused = false, this.rAF = requestAnimationFrame(this.count)) : this.printValue(this.endVal)); | ||
}, t.prototype.pauseResume = function() { | ||
this.finalEndVal !== null ? this.useEasing = false : this.useEasing = this.options.useEasing; | ||
}, i2.prototype.start = function(t2) { | ||
this.error || (t2 && (this.options.onCompleteCallback = t2), this.duration > 0 ? (this.determineDirectionAndSmartEasing(), this.paused = false, this.rAF = requestAnimationFrame(this.count)) : this.printValue(this.endVal)); | ||
}, i2.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() { | ||
}, i2.prototype.reset = function() { | ||
cancelAnimationFrame(this.rAF), this.paused = true, this.resetDuration(), this.startVal = this.validateValue(this.options.startVal), this.frameVal = this.startVal, this.printValue(this.startVal); | ||
}, t.prototype.update = function(t2) { | ||
cancelAnimationFrame(this.rAF), this.startTime = null, this.endVal = this.validateValue(t2), this.endVal !== this.frameVal && (this.startVal = this.frameVal, this.finalEndVal || this.resetDuration(), this.finalEndVal = null, this.determineDirectionAndSmartEasing(), this.rAF = requestAnimationFrame(this.count)); | ||
}, t.prototype.printValue = function(t2) { | ||
var i = this.formattingFn(t2); | ||
this.el.tagName === "INPUT" ? this.el.value = i : this.el.tagName === "text" || this.el.tagName === "tspan" ? this.el.textContent = i : this.el.innerHTML = i; | ||
}, t.prototype.ensureNumber = function(t2) { | ||
}, i2.prototype.update = function(t2) { | ||
cancelAnimationFrame(this.rAF), this.startTime = null, this.endVal = this.validateValue(t2), this.endVal !== this.frameVal && (this.startVal = this.frameVal, this.finalEndVal == null && this.resetDuration(), this.finalEndVal = null, this.determineDirectionAndSmartEasing(), this.rAF = requestAnimationFrame(this.count)); | ||
}, i2.prototype.printValue = function(t2) { | ||
var i3; | ||
if (this.el) { | ||
var n = this.formattingFn(t2); | ||
if ((i3 = this.options.plugin) === null || i3 === void 0 ? void 0 : i3.render) | ||
this.options.plugin.render(this.el, n); | ||
else if (this.el.tagName === "INPUT") | ||
this.el.value = n; | ||
else | ||
this.el.tagName === "text" || this.el.tagName === "tspan" ? this.el.textContent = n : this.el.innerHTML = n; | ||
} | ||
}, i2.prototype.ensureNumber = function(t2) { | ||
return typeof t2 == "number" && !isNaN(t2); | ||
}, t.prototype.validateValue = function(t2) { | ||
var i = Number(t2); | ||
return this.ensureNumber(i) ? i : (this.error = "[CountUp] invalid start or end value: " + t2, null); | ||
}, t.prototype.resetDuration = function() { | ||
}, i2.prototype.validateValue = function(t2) { | ||
var i3 = Number(t2); | ||
return this.ensureNumber(i3) ? i3 : (this.error = "[CountUp] invalid start or end value: ".concat(t2), null); | ||
}, i2.prototype.resetDuration = function() { | ||
this.startTime = null, this.duration = 1e3 * Number(this.options.duration), this.remaining = this.duration; | ||
}, t; | ||
}, i2; | ||
}(); | ||
@@ -110,3 +120,3 @@ const _hoisted_1 = { class: "countup-wrap" }; | ||
autoplay: { type: Boolean, default: true }, | ||
loop: { type: [Boolean, Number, String], default: false }, | ||
loop: { type: [Boolean, Number], default: false }, | ||
delay: { default: 0 }, | ||
@@ -126,3 +136,3 @@ options: { default: void 0 } | ||
const duration = Number(props.duration); | ||
countUp.value = new CountUp(elRef.value, endVal, __spreadValues({ | ||
countUp.value = new i(elRef.value, endVal, __spreadValues({ | ||
startVal, | ||
@@ -129,0 +139,0 @@ duration, |
@@ -1,1 +0,1 @@ | ||
var D=Object.defineProperty,_=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var b=(n,o,d)=>o in n?D(n,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):n[o]=d,E=(n,o)=>{for(var d in o||(o={}))P.call(o,d)&&b(n,d,o[d]);if(A)for(var d of A(o))C.call(o,d)&&b(n,d,o[d]);return n},S=(n,o)=>_(n,x(o));var VueCountUp=function(n){"use strict";var o=globalThis&&globalThis.__assign||function(){return(o=Object.assign||function(l){for(var a,e=1,i=arguments.length;e<i;e++)for(var t in a=arguments[e])Object.prototype.hasOwnProperty.call(a,t)&&(l[t]=a[t]);return l}).apply(this,arguments)},d=function(){function l(a,e,i){var t=this;this.endVal=e,this.options=i,this.version="2.1.0",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(r){t.startTime||(t.startTime=r);var u=r-t.startTime;t.remaining=t.duration-u,t.useEasing?t.countDown?t.frameVal=t.startVal-t.easingFn(u,0,t.startVal-t.endVal,t.duration):t.frameVal=t.easingFn(u,t.startVal,t.endVal-t.startVal,t.duration):t.countDown?t.frameVal=t.startVal-(t.startVal-t.endVal)*(u/t.duration):t.frameVal=t.startVal+(t.endVal-t.startVal)*(u/t.duration),t.countDown?t.frameVal=t.frameVal<t.endVal?t.endVal:t.frameVal:t.frameVal=t.frameVal>t.endVal?t.endVal:t.frameVal,t.frameVal=Number(t.frameVal.toFixed(t.options.decimalPlaces)),t.printValue(t.frameVal),u<t.duration?t.rAF=requestAnimationFrame(t.count):t.finalEndVal!==null?t.update(t.finalEndVal):t.callback&&t.callback()},this.formatNumber=function(r){var u,p,c,f,y=r<0?"-":"";u=Math.abs(r).toFixed(t.options.decimalPlaces);var m=(u+="").split(".");if(p=m[0],c=m.length>1?t.options.decimal+m[1]:"",t.options.useGrouping){f="";for(var V=0,w=p.length;V<w;++V)V!==0&&V%3==0&&(f=t.options.separator+f),f=p[w-V-1]+f;p=f}return t.options.numerals&&t.options.numerals.length&&(p=p.replace(/[0-9]/g,function(s){return t.options.numerals[+s]}),c=c.replace(/[0-9]/g,function(s){return t.options.numerals[+s]})),y+t.options.prefix+p+c+t.options.suffix},this.easeOutExpo=function(r,u,p,c){return p*(1-Math.pow(2,-10*r/c))*1024/1023+u},this.options=o(o({},this.defaults),i),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(e),this.options.decimalPlaces=Math.max(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=typeof a=="string"?document.getElementById(a):a,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined",window!==void 0&&this.options.enableScrollSpy&&(this.error?console.error(this.error,a):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push(function(){return t.handleScroll(t)}),window.onscroll=function(){window.onScrollFns.forEach(function(r){return r()})},this.handleScroll(this)))}return l.prototype.handleScroll=function(a){if(a&&window){var e=window.innerHeight+window.scrollY,i=a.el.offsetTop+a.el.offsetHeight;i<e&&i>window.scrollY&&a.paused?(a.paused=!1,setTimeout(function(){return a.start()},a.options.scrollSpyDelay)):window.scrollY>i&&!a.paused&&a.reset()}},l.prototype.determineDirectionAndSmartEasing=function(){var a=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>a;var e=a-this.startVal;if(Math.abs(e)>this.options.smartEasingThreshold){this.finalEndVal=a;var i=this.countDown?1:-1;this.endVal=a+i*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=a,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},l.prototype.start=function(a){this.error||(this.callback=a,this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},l.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},l.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)},l.prototype.update=function(a){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(a),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},l.prototype.printValue=function(a){var e=this.formattingFn(a);this.el.tagName==="INPUT"?this.el.value=e:this.el.tagName==="text"||this.el.tagName==="tspan"?this.el.textContent=e:this.el.innerHTML=e},l.prototype.ensureNumber=function(a){return typeof a=="number"&&!isNaN(a)},l.prototype.validateValue=function(a){var e=Number(a);return this.ensureNumber(e)?e:(this.error="[CountUp] invalid start or end value: "+a,null)},l.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},l}();const N={class:"countup-wrap"},T={name:"CountUp"};return n.defineComponent(S(E({},T),{props:{endVal:null,startVal:{default:0},duration:{default:2.5},decimalPlaces:{default:0},autoplay:{type:Boolean,default:!0},loop:{type:[Boolean,Number,String],default:!1},delay:{default:0},options:{default:void 0}},emits:["init","finished"],setup(l,{expose:a,emit:e}){const i=l;let t=n.ref(),r=n.ref();const u=()=>{if(!t.value)return;const s=Number(i.startVal),h=Number(i.endVal),g=Number(i.duration);if(r.value=new d(t.value,h,E({startVal:s,duration:g,decimalPlaces:i.decimalPlaces},i.options)),r.value.error){console.error(r.value.error);return}e("init",r.value)},p=s=>{var h;(h=r.value)==null||h.start(s)};n.watch(()=>i.endVal,s=>{var h;i.autoplay&&((h=r.value)==null||h.update(s))});const c=n.ref(!1);let f=0;const y=()=>{f++,p(()=>{typeof i.loop=="boolean"&&i.loop||i.loop>f?V(()=>{var h;(h=r.value)==null||h.reset(),y()},i.delay):c.value=!0})};n.watch(c,s=>{s&&e("finished")}),n.onMounted(()=>{u(),i.autoplay&&y()}),n.onUnmounted(()=>{var s;cancelAnimationFrame(m),(s=r.value)==null||s.reset()});let m;const V=(s,h=1)=>{let g;function F(v){g||(g=v),v-g<h*1e3?m=requestAnimationFrame(F):s()}m=requestAnimationFrame(F)};return a({init:u,restart:()=>{u(),p()}}),(s,h)=>(n.openBlock(),n.createElementBlock("div",N,[n.renderSlot(s.$slots,"prefix"),n.createElementVNode("span",{ref_key:"elRef",ref:t},null,512),n.renderSlot(s.$slots,"suffix")]))}}))}(Vue); | ||
var D=Object.defineProperty,T=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var S=(i,r,d)=>r in i?D(i,r,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[r]=d,E=(i,r)=>{for(var d in r||(r={}))_.call(r,d)&&S(i,d,r[d]);if(A)for(var d of A(r))P.call(r,d)&&S(i,d,r[d]);return i},b=(i,r)=>T(i,x(r));var VueCountUp=function(i){"use strict";var r=function(){return r=Object.assign||function(l){for(var n,o=1,e=arguments.length;o<e;o++)for(var t in n=arguments[o])Object.prototype.hasOwnProperty.call(n,t)&&(l[t]=n[t]);return l},r.apply(this,arguments)},d=function(){function l(n,o,e){var t=this;this.endVal=o,this.options=e,this.version="2.6.2",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(a){t.startTime||(t.startTime=a);var h=a-t.startTime;t.remaining=t.duration-h,t.useEasing?t.countDown?t.frameVal=t.startVal-t.easingFn(h,0,t.startVal-t.endVal,t.duration):t.frameVal=t.easingFn(h,t.startVal,t.endVal-t.startVal,t.duration):t.frameVal=t.startVal+(t.endVal-t.startVal)*(h/t.duration);var p=t.countDown?t.frameVal<t.endVal:t.frameVal>t.endVal;t.frameVal=p?t.endVal:t.frameVal,t.frameVal=Number(t.frameVal.toFixed(t.options.decimalPlaces)),t.printValue(t.frameVal),h<t.duration?t.rAF=requestAnimationFrame(t.count):t.finalEndVal!==null?t.update(t.finalEndVal):t.options.onCompleteCallback&&t.options.onCompleteCallback()},this.formatNumber=function(a){var h,p,c,f,g=a<0?"-":"";h=Math.abs(a).toFixed(t.options.decimalPlaces);var V=(h+="").split(".");if(p=V[0],c=V.length>1?t.options.decimal+V[1]:"",t.options.useGrouping){f="";for(var y=3,w=0,s=0,u=p.length;s<u;++s)t.options.useIndianSeparators&&s===4&&(y=2,w=1),s!==0&&w%y==0&&(f=t.options.separator+f),w++,f=p[u-s-1]+f;p=f}return t.options.numerals&&t.options.numerals.length&&(p=p.replace(/[0-9]/g,function(m){return t.options.numerals[+m]}),c=c.replace(/[0-9]/g,function(m){return t.options.numerals[+m]})),g+t.options.prefix+p+c+t.options.suffix},this.easeOutExpo=function(a,h,p,c){return p*(1-Math.pow(2,-10*a/c))*1024/1023+h},this.options=r(r({},this.defaults),e),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(o),this.options.decimalPlaces=Math.max(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=typeof n=="string"?document.getElementById(n):n,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined",typeof window!="undefined"&&this.options.enableScrollSpy&&(this.error?console.error(this.error,n):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push(function(){return t.handleScroll(t)}),window.onscroll=function(){window.onScrollFns.forEach(function(a){return a()})},this.handleScroll(this)))}return l.prototype.handleScroll=function(n){if(n&&window&&!n.once){var o=window.innerHeight+window.scrollY,e=n.el.getBoundingClientRect(),t=e.top+window.pageYOffset,a=e.top+e.height+window.pageYOffset;a<o&&a>window.scrollY&&n.paused?(n.paused=!1,setTimeout(function(){return n.start()},n.options.scrollSpyDelay),n.options.scrollSpyOnce&&(n.once=!0)):(window.scrollY>a||t>o)&&!n.paused&&n.reset()}},l.prototype.determineDirectionAndSmartEasing=function(){var n=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>n;var o=n-this.startVal;if(Math.abs(o)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=n;var e=this.countDown?1:-1;this.endVal=n+e*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=n,this.finalEndVal=null;this.finalEndVal!==null?this.useEasing=!1:this.useEasing=this.options.useEasing},l.prototype.start=function(n){this.error||(n&&(this.options.onCompleteCallback=n),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},l.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},l.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)},l.prototype.update=function(n){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(n),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal==null&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},l.prototype.printValue=function(n){var o;if(this.el){var e=this.formattingFn(n);!((o=this.options.plugin)===null||o===void 0)&&o.render?this.options.plugin.render(this.el,e):this.el.tagName==="INPUT"?this.el.value=e:this.el.tagName==="text"||this.el.tagName==="tspan"?this.el.textContent=e:this.el.innerHTML=e}},l.prototype.ensureNumber=function(n){return typeof n=="number"&&!isNaN(n)},l.prototype.validateValue=function(n){var o=Number(n);return this.ensureNumber(o)?o:(this.error="[CountUp] invalid start or end value: ".concat(n),null)},l.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},l}();const N={class:"countup-wrap"},C={name:"CountUp"};return i.defineComponent(b(E({},C),{props:{endVal:null,startVal:{default:0},duration:{default:2.5},decimalPlaces:{default:0},autoplay:{type:Boolean,default:!0},loop:{type:[Boolean,Number],default:!1},delay:{default:0},options:{default:void 0}},emits:["init","finished"],setup(l,{expose:n,emit:o}){const e=l;let t=i.ref(),a=i.ref();const h=()=>{if(!t.value)return;const s=Number(e.startVal),u=Number(e.endVal),m=Number(e.duration);if(a.value=new d(t.value,u,E({startVal:s,duration:m,decimalPlaces:e.decimalPlaces},e.options)),a.value.error){console.error(a.value.error);return}o("init",a.value)},p=s=>{var u;(u=a.value)==null||u.start(s)};i.watch(()=>e.endVal,s=>{var u;e.autoplay&&((u=a.value)==null||u.update(s))});const c=i.ref(!1);let f=0;const g=()=>{f++,p(()=>{typeof e.loop=="boolean"&&e.loop||e.loop>f?y(()=>{var u;(u=a.value)==null||u.reset(),g()},e.delay):c.value=!0})};i.watch(c,s=>{s&&o("finished")}),i.onMounted(()=>{h(),e.autoplay&&g()}),i.onUnmounted(()=>{var s;cancelAnimationFrame(V),(s=a.value)==null||s.reset()});let V;const y=(s,u=1)=>{let m;function F(v){m||(m=v),v-m<u*1e3?V=requestAnimationFrame(F):s()}V=requestAnimationFrame(F)};return n({init:h,restart:()=>{h(),p()}}),(s,u)=>(i.openBlock(),i.createElementBlock("div",N,[i.renderSlot(s.$slots,"prefix"),i.createElementVNode("span",{ref_key:"elRef",ref:t},null,512),i.renderSlot(s.$slots,"suffix")]))}}))}(Vue); |
@@ -1,1 +0,1 @@ | ||
var D=Object.defineProperty,_=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var b=(n,a,d)=>a in n?D(n,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):n[a]=d,E=(n,a)=>{for(var d in a||(a={}))P.call(a,d)&&b(n,d,a[d]);if(A)for(var d of A(a))C.call(a,d)&&b(n,d,a[d]);return n},S=(n,a)=>_(n,x(a));(function(n,a){typeof exports=="object"&&typeof module!="undefined"?module.exports=a(require("vue")):typeof define=="function"&&define.amd?define(["vue"],a):(n=typeof globalThis!="undefined"?globalThis:n||self,n.VueCountUp=a(n.Vue))})(this,function(n){"use strict";var a=globalThis&&globalThis.__assign||function(){return(a=Object.assign||function(l){for(var e,s=1,i=arguments.length;s<i;s++)for(var t in e=arguments[s])Object.prototype.hasOwnProperty.call(e,t)&&(l[t]=e[t]);return l}).apply(this,arguments)},d=function(){function l(e,s,i){var t=this;this.endVal=s,this.options=i,this.version="2.1.0",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.count=function(r){t.startTime||(t.startTime=r);var u=r-t.startTime;t.remaining=t.duration-u,t.useEasing?t.countDown?t.frameVal=t.startVal-t.easingFn(u,0,t.startVal-t.endVal,t.duration):t.frameVal=t.easingFn(u,t.startVal,t.endVal-t.startVal,t.duration):t.countDown?t.frameVal=t.startVal-(t.startVal-t.endVal)*(u/t.duration):t.frameVal=t.startVal+(t.endVal-t.startVal)*(u/t.duration),t.countDown?t.frameVal=t.frameVal<t.endVal?t.endVal:t.frameVal:t.frameVal=t.frameVal>t.endVal?t.endVal:t.frameVal,t.frameVal=Number(t.frameVal.toFixed(t.options.decimalPlaces)),t.printValue(t.frameVal),u<t.duration?t.rAF=requestAnimationFrame(t.count):t.finalEndVal!==null?t.update(t.finalEndVal):t.callback&&t.callback()},this.formatNumber=function(r){var u,p,f,c,y=r<0?"-":"";u=Math.abs(r).toFixed(t.options.decimalPlaces);var m=(u+="").split(".");if(p=m[0],f=m.length>1?t.options.decimal+m[1]:"",t.options.useGrouping){c="";for(var V=0,w=p.length;V<w;++V)V!==0&&V%3==0&&(c=t.options.separator+c),c=p[w-V-1]+c;p=c}return t.options.numerals&&t.options.numerals.length&&(p=p.replace(/[0-9]/g,function(o){return t.options.numerals[+o]}),f=f.replace(/[0-9]/g,function(o){return t.options.numerals[+o]})),y+t.options.prefix+p+f+t.options.suffix},this.easeOutExpo=function(r,u,p,f){return p*(1-Math.pow(2,-10*r/f))*1024/1023+u},this.options=a(a({},this.defaults),i),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(s),this.options.decimalPlaces=Math.max(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=typeof e=="string"?document.getElementById(e):e,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined",window!==void 0&&this.options.enableScrollSpy&&(this.error?console.error(this.error,e):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push(function(){return t.handleScroll(t)}),window.onscroll=function(){window.onScrollFns.forEach(function(r){return r()})},this.handleScroll(this)))}return l.prototype.handleScroll=function(e){if(e&&window){var s=window.innerHeight+window.scrollY,i=e.el.offsetTop+e.el.offsetHeight;i<s&&i>window.scrollY&&e.paused?(e.paused=!1,setTimeout(function(){return e.start()},e.options.scrollSpyDelay)):window.scrollY>i&&!e.paused&&e.reset()}},l.prototype.determineDirectionAndSmartEasing=function(){var e=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>e;var s=e-this.startVal;if(Math.abs(s)>this.options.smartEasingThreshold){this.finalEndVal=e;var i=this.countDown?1:-1;this.endVal=e+i*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=e,this.finalEndVal=null;this.finalEndVal?this.useEasing=!1:this.useEasing=this.options.useEasing},l.prototype.start=function(e){this.error||(this.callback=e,this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},l.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},l.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)},l.prototype.update=function(e){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(e),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal||this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},l.prototype.printValue=function(e){var s=this.formattingFn(e);this.el.tagName==="INPUT"?this.el.value=s:this.el.tagName==="text"||this.el.tagName==="tspan"?this.el.textContent=s:this.el.innerHTML=s},l.prototype.ensureNumber=function(e){return typeof e=="number"&&!isNaN(e)},l.prototype.validateValue=function(e){var s=Number(e);return this.ensureNumber(s)?s:(this.error="[CountUp] invalid start or end value: "+e,null)},l.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},l}();const T={class:"countup-wrap"},N={name:"CountUp"};return n.defineComponent(S(E({},N),{props:{endVal:null,startVal:{default:0},duration:{default:2.5},decimalPlaces:{default:0},autoplay:{type:Boolean,default:!0},loop:{type:[Boolean,Number,String],default:!1},delay:{default:0},options:{default:void 0}},emits:["init","finished"],setup(l,{expose:e,emit:s}){const i=l;let t=n.ref(),r=n.ref();const u=()=>{if(!t.value)return;const o=Number(i.startVal),h=Number(i.endVal),g=Number(i.duration);if(r.value=new d(t.value,h,E({startVal:o,duration:g,decimalPlaces:i.decimalPlaces},i.options)),r.value.error){console.error(r.value.error);return}s("init",r.value)},p=o=>{var h;(h=r.value)==null||h.start(o)};n.watch(()=>i.endVal,o=>{var h;i.autoplay&&((h=r.value)==null||h.update(o))});const f=n.ref(!1);let c=0;const y=()=>{c++,p(()=>{typeof i.loop=="boolean"&&i.loop||i.loop>c?V(()=>{var h;(h=r.value)==null||h.reset(),y()},i.delay):f.value=!0})};n.watch(f,o=>{o&&s("finished")}),n.onMounted(()=>{u(),i.autoplay&&y()}),n.onUnmounted(()=>{var o;cancelAnimationFrame(m),(o=r.value)==null||o.reset()});let m;const V=(o,h=1)=>{let g;function F(v){g||(g=v),v-g<h*1e3?m=requestAnimationFrame(F):o()}m=requestAnimationFrame(F)};return e({init:u,restart:()=>{u(),p()}}),(o,h)=>(n.openBlock(),n.createElementBlock("div",T,[n.renderSlot(o.$slots,"prefix"),n.createElementVNode("span",{ref_key:"elRef",ref:t},null,512),n.renderSlot(o.$slots,"suffix")]))}}))}); | ||
var C=Object.defineProperty,D=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var S=(n,o,d)=>o in n?C(n,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):n[o]=d,E=(n,o)=>{for(var d in o||(o={}))_.call(o,d)&&S(n,d,o[d]);if(A)for(var d of A(o))P.call(o,d)&&S(n,d,o[d]);return n},b=(n,o)=>D(n,x(o));(function(n,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o(require("vue")):typeof define=="function"&&define.amd?define(["vue"],o):(n=typeof globalThis!="undefined"?globalThis:n||self,n.VueCountUp=o(n.Vue))})(this,function(n){"use strict";var o=function(){return o=Object.assign||function(l){for(var e,r=1,i=arguments.length;r<i;r++)for(var t in e=arguments[r])Object.prototype.hasOwnProperty.call(e,t)&&(l[t]=e[t]);return l},o.apply(this,arguments)},d=function(){function l(e,r,i){var t=this;this.endVal=r,this.options=i,this.version="2.6.2",this.defaults={startVal:0,decimalPlaces:0,duration:2,useEasing:!0,useGrouping:!0,useIndianSeparators:!1,smartEasingThreshold:999,smartEasingAmount:333,separator:",",decimal:".",prefix:"",suffix:"",enableScrollSpy:!1,scrollSpyDelay:200,scrollSpyOnce:!1},this.finalEndVal=null,this.useEasing=!0,this.countDown=!1,this.error="",this.startVal=0,this.paused=!0,this.once=!1,this.count=function(a){t.startTime||(t.startTime=a);var h=a-t.startTime;t.remaining=t.duration-h,t.useEasing?t.countDown?t.frameVal=t.startVal-t.easingFn(h,0,t.startVal-t.endVal,t.duration):t.frameVal=t.easingFn(h,t.startVal,t.endVal-t.startVal,t.duration):t.frameVal=t.startVal+(t.endVal-t.startVal)*(h/t.duration);var p=t.countDown?t.frameVal<t.endVal:t.frameVal>t.endVal;t.frameVal=p?t.endVal:t.frameVal,t.frameVal=Number(t.frameVal.toFixed(t.options.decimalPlaces)),t.printValue(t.frameVal),h<t.duration?t.rAF=requestAnimationFrame(t.count):t.finalEndVal!==null?t.update(t.finalEndVal):t.options.onCompleteCallback&&t.options.onCompleteCallback()},this.formatNumber=function(a){var h,p,f,c,g=a<0?"-":"";h=Math.abs(a).toFixed(t.options.decimalPlaces);var V=(h+="").split(".");if(p=V[0],f=V.length>1?t.options.decimal+V[1]:"",t.options.useGrouping){c="";for(var y=3,w=0,s=0,u=p.length;s<u;++s)t.options.useIndianSeparators&&s===4&&(y=2,w=1),s!==0&&w%y==0&&(c=t.options.separator+c),w++,c=p[u-s-1]+c;p=c}return t.options.numerals&&t.options.numerals.length&&(p=p.replace(/[0-9]/g,function(m){return t.options.numerals[+m]}),f=f.replace(/[0-9]/g,function(m){return t.options.numerals[+m]})),g+t.options.prefix+p+f+t.options.suffix},this.easeOutExpo=function(a,h,p,f){return p*(1-Math.pow(2,-10*a/f))*1024/1023+h},this.options=o(o({},this.defaults),i),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(r),this.options.decimalPlaces=Math.max(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=typeof e=="string"?document.getElementById(e):e,this.el?this.printValue(this.startVal):this.error="[CountUp] target is null or undefined",typeof window!="undefined"&&this.options.enableScrollSpy&&(this.error?console.error(this.error,e):(window.onScrollFns=window.onScrollFns||[],window.onScrollFns.push(function(){return t.handleScroll(t)}),window.onscroll=function(){window.onScrollFns.forEach(function(a){return a()})},this.handleScroll(this)))}return l.prototype.handleScroll=function(e){if(e&&window&&!e.once){var r=window.innerHeight+window.scrollY,i=e.el.getBoundingClientRect(),t=i.top+window.pageYOffset,a=i.top+i.height+window.pageYOffset;a<r&&a>window.scrollY&&e.paused?(e.paused=!1,setTimeout(function(){return e.start()},e.options.scrollSpyDelay),e.options.scrollSpyOnce&&(e.once=!0)):(window.scrollY>a||t>r)&&!e.paused&&e.reset()}},l.prototype.determineDirectionAndSmartEasing=function(){var e=this.finalEndVal?this.finalEndVal:this.endVal;this.countDown=this.startVal>e;var r=e-this.startVal;if(Math.abs(r)>this.options.smartEasingThreshold&&this.options.useEasing){this.finalEndVal=e;var i=this.countDown?1:-1;this.endVal=e+i*this.options.smartEasingAmount,this.duration=this.duration/2}else this.endVal=e,this.finalEndVal=null;this.finalEndVal!==null?this.useEasing=!1:this.useEasing=this.options.useEasing},l.prototype.start=function(e){this.error||(e&&(this.options.onCompleteCallback=e),this.duration>0?(this.determineDirectionAndSmartEasing(),this.paused=!1,this.rAF=requestAnimationFrame(this.count)):this.printValue(this.endVal))},l.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},l.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)},l.prototype.update=function(e){cancelAnimationFrame(this.rAF),this.startTime=null,this.endVal=this.validateValue(e),this.endVal!==this.frameVal&&(this.startVal=this.frameVal,this.finalEndVal==null&&this.resetDuration(),this.finalEndVal=null,this.determineDirectionAndSmartEasing(),this.rAF=requestAnimationFrame(this.count))},l.prototype.printValue=function(e){var r;if(this.el){var i=this.formattingFn(e);!((r=this.options.plugin)===null||r===void 0)&&r.render?this.options.plugin.render(this.el,i):this.el.tagName==="INPUT"?this.el.value=i:this.el.tagName==="text"||this.el.tagName==="tspan"?this.el.textContent=i:this.el.innerHTML=i}},l.prototype.ensureNumber=function(e){return typeof e=="number"&&!isNaN(e)},l.prototype.validateValue=function(e){var r=Number(e);return this.ensureNumber(r)?r:(this.error="[CountUp] invalid start or end value: ".concat(e),null)},l.prototype.resetDuration=function(){this.startTime=null,this.duration=1e3*Number(this.options.duration),this.remaining=this.duration},l}();const N={class:"countup-wrap"},T={name:"CountUp"};return n.defineComponent(b(E({},T),{props:{endVal:null,startVal:{default:0},duration:{default:2.5},decimalPlaces:{default:0},autoplay:{type:Boolean,default:!0},loop:{type:[Boolean,Number],default:!1},delay:{default:0},options:{default:void 0}},emits:["init","finished"],setup(l,{expose:e,emit:r}){const i=l;let t=n.ref(),a=n.ref();const h=()=>{if(!t.value)return;const s=Number(i.startVal),u=Number(i.endVal),m=Number(i.duration);if(a.value=new d(t.value,u,E({startVal:s,duration:m,decimalPlaces:i.decimalPlaces},i.options)),a.value.error){console.error(a.value.error);return}r("init",a.value)},p=s=>{var u;(u=a.value)==null||u.start(s)};n.watch(()=>i.endVal,s=>{var u;i.autoplay&&((u=a.value)==null||u.update(s))});const f=n.ref(!1);let c=0;const g=()=>{c++,p(()=>{typeof i.loop=="boolean"&&i.loop||i.loop>c?y(()=>{var u;(u=a.value)==null||u.reset(),g()},i.delay):f.value=!0})};n.watch(f,s=>{s&&r("finished")}),n.onMounted(()=>{h(),i.autoplay&&g()}),n.onUnmounted(()=>{var s;cancelAnimationFrame(V),(s=a.value)==null||s.reset()});let V;const y=(s,u=1)=>{let m;function F(v){m||(m=v),v-m<u*1e3?V=requestAnimationFrame(F):s()}V=requestAnimationFrame(F)};return e({init:h,restart:()=>{h(),p()}}),(s,u)=>(n.openBlock(),n.createElementBlock("div",N,[n.renderSlot(s.$slots,"prefix"),n.createElementVNode("span",{ref_key:"elRef",ref:t},null,512),n.renderSlot(s.$slots,"suffix")]))}}))}); |
{ | ||
"name": "vue-countup-v3", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Vue 3 component wrap for countUp.js,and expand some features.", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"dependencies": { | ||
"countup.js": "^2.1.0" | ||
"countup.js": "^2.6.2" | ||
}, | ||
@@ -48,0 +48,0 @@ "peerDependencies": { |
# vue-countup-v3 [](https://www.npmjs.com/package/vue-countup-v3)  | ||
> A Vue 3 component for animation counting, wrap for countUp.js(v2.6.2) and expand some features. | ||
> 基于 countup.js 封装的 vue3 计数动画组件,并扩展一些功能。 | ||
> Vue 3 component for animation counting, wrap for countUp.js and expand some features. | ||
 | ||
@@ -18,8 +17,2 @@ | ||
yarn | ||
```bash | ||
yarn add vue-countup-v3 | ||
``` | ||
<details> | ||
@@ -109,3 +102,2 @@ <summary><strong>cdn</strong></summary> | ||
console.log('finished') | ||
countUp?.reset() | ||
} | ||
@@ -131,4 +123,2 @@ </script> | ||
以下属性同 coutup.js 配置项(same as countup.js properties) | ||
| Name | Type | Default | Description | Version | | ||
@@ -140,12 +130,7 @@ | :------- | :--------------- | :------ | :------------------------------------------------------------------- | :------- | | ||
| decimalPlaces | Number | 0 | 小数点位数 | 1.1.0 | | ||
| options | Object | - | [countUp.js](https://github.com/inorganik/countUp.js) options 配置项 | | | ||
| autoplay | Boolean | true | 是否自动计数 | | | ||
| loop | Boolean \| Number | false | 循环次数,有限次数 / 无限循环 | | | ||
| delay | Number | 0 | loop 循环的间隔时间,单位:秒 | | | ||
| options | Object | - | [countUp.js Options](https://github.com/inorganik/countUp.js#usage) | | | ||
以下为组件特有属性(extension properties) | ||
| Name | Type | Default | Description | | ||
| :------- | :---------------- | :------ | :---------------------------- | | ||
| autoplay | Boolean | true | 是否自动计数 | | ||
| loop | Boolean \| Number | false | 循环次数,有限次数 / 无限循环 | | ||
| delay | Number | 0 | loop 循环的间隔时间,单位:秒 | | ||
## 插槽(slots) | ||
@@ -182,6 +167,4 @@ | ||
see more [countUp.js](https://github.com/inorganik/countUp.js) | ||
### 配置项(**Options**) | ||
### 配置项(**Options** ) | ||
```typescript | ||
@@ -193,3 +176,4 @@ interface CountUpOptions { | ||
useGrouping?: boolean // example: 1,000 vs 1000 (true) 是否使用千分位 | ||
useEasing?: boolean // ease animation (true) 是否开启动画过渡,默认动画函数为easeOutExpo | ||
useIndianSeparators?: boolean; // example: 1,00,000 vs 100,000 (false) | ||
useEasing?: boolean // ease animation (true) 是否开启动画过渡,默认动画函数为 easeOutExpo | ||
smartEasingThreshold?: number // smooth easing for large numbers above this if useEasing (999) | ||
@@ -207,8 +191,11 @@ smartEasingAmount?: number // amount to be eased for numbers above threshold (333) | ||
scrollSpyDelay?: number // delay (ms) after target comes into view 目标进入可视范围内后的延迟时间(毫秒) | ||
scrollSpyOnce?: boolean; // run only once | ||
onCompleteCallback?: () => any; // gets called when animation completes | ||
plugin?: CountUpPlugin; // for alternate animations | ||
} | ||
``` | ||
see more [countUp.js](https://github.com/inorganik/countUp.js) | ||
### **方法(Methods)** | ||
开始计数 | ||
开始计数(Start animation) | ||
@@ -219,3 +206,3 @@ ```js | ||
Toggle pause/resume 切换暂停/恢复 | ||
切换暂停/恢复(Toggle pause/resume) | ||
@@ -226,3 +213,3 @@ ```js | ||
Reset the animation: 重置数值 | ||
重置数值(Reset the animation) | ||
@@ -233,3 +220,3 @@ ```js | ||
Update the end value and animate: 修改结束值且继续动画 | ||
修改结束值且继续动画(Update the end value and animate) | ||
@@ -236,0 +223,0 @@ ```js |
40689
2.62%388
2.92%220
-5.58%Updated