!function(a,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n(require,exports,module):a.countup=n()}(this,function(a,n,t){var e=function(a,n,t,e,i,r){function o(a){a=a.tofixed(l.decimals),a+="";var n,t,e,i,r,o;if(n=a.split("."),t=n[0],e=n.length>1?l.options.decimal+n[1]:"",l.options.usegrouping){for(i="",r=0,o=t.length;rl.endval,l.frameval=l.startval,l.initialized=!0,!0):(l.error="[countup] startval ("+n+") or endval ("+t+") is not a number",!1)):(l.error="[countup] target is null or undefined",!1))},l.printvalue=function(a){var n=l.options.formattingfn(a);"input"===l.d.tagname?this.d.value=n:"text"===l.d.tagname||"tspan"===l.d.tagname?this.d.textcontent=n:this.d.innerhtml=n},l.count=function(a){l.starttime||(l.starttime=a),l.timestamp=a;var n=a-l.starttime;l.remaining=l.duration-n,l.options.useeasing?l.countdown?l.frameval=l.startval-l.options.easingfn(n,0,l.startval-l.endval,l.duration):l.frameval=l.options.easingfn(n,l.startval,l.endval-l.startval,l.duration):l.countdown?l.frameval=l.startval-(l.startval-l.endval)*(n/l.duration):l.frameval=l.startval+(l.endval-l.startval)*(n/l.duration),l.countdown?l.frameval=l.framevall.endval?l.endval:l.frameval,l.frameval=math.round(l.frameval*l.dec)/l.dec,l.printvalue(l.frameval),nl.endval,l.raf=requestanimationframe(l.count))}},l.initialize()&&l.printvalue(l.startval)};return e}); $(function () { var countcxarr = []; var countcx = function () { $(".numcount").each(function (i, dom) { if (countcxarr[i] && countcxarr[i] === true) { return; } var st; var nctop; st = $(window).scrolltop(); nctop = $(dom).offset().top; var id, decimals, startval, endval, duration; if (st > nctop - $(window).height() && st < nctop) { $(dom) .find(".numcx") .each(function () { id = $(this).attr("id"); (decimals = $(this).attr("data-decimals")), (startval = $(this).attr("data-startval")), (endval = $(this).attr("data-endval")), (duration = $(this).attr("data-speed")); new countup(id, startval, endval, decimals, duration, { useeasing: true, //效果 separator: "", //数字分隔符 }) .start(); // target:目标元素id, startval:你想要开始的值, endval:你想要到达的值, decimals:小数位数,默认值为0, duration:动画持续时间为秒,默认值为2, options:选项的可选对象 countcxarr[i] = true; }); } }); }; countcx(); $(window).on("scroll", function () { countcx(); }); });