!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; r < o; ++r) 0 !== r && r % 3 === 0 && (i = l.options.separator + i), i = t[o - r - 1] + i; t = i } return l.options.numerals.length && (t = t.replace(/[0-9]/g, function(a) { return l.options.numerals[+a] }), e = e.replace(/[0-9]/g, function(a) { return l.options.numerals[+a] })), l.options.prefix + t + e + l.options.suffix } function u(a, n, t, e) { return t * (-math.pow(2, -10 * a / e) + 1) * 1024 / 1023 + n } function s(a) { return "number" == typeof a && !isnan(a) } var l = this; if (l.version = function() { return "1.9.2" } , l.options = { useeasing: !0, usegrouping: !0, separator: ",", decimal: ".", easingfn: u, formattingfn: o, prefix: "", suffix: "", numerals: [] }, r && "object" == typeof r) for (var m in l.options) r.hasownproperty(m) && null !== r[m] && (l.options[m] = r[m]); "" === l.options.separator ? l.options.usegrouping = !1 : l.options.separator = "" + l.options.separator; for (var d = 0, c = ["webkit", "moz", "ms", "o"], f = 0; f < c.length && !window.requestanimationframe; ++f) window.requestanimationframe = window[c[f] + "requestanimationframe"], window.cancelanimationframe = window[c[f] + "cancelanimationframe"] || window[c[f] + "cancelrequestanimationframe"]; window.requestanimationframe || (window.requestanimationframe = function(a, n) { var t = (new date).gettime() , e = math.max(0, 16 - (t - d)) , i = window.settimeout(function() { a(t + e) }, e); return d = t + e, i } ), l.initialize = function() { return !!l.initialized || (l.error = "", l.d = "string" == typeof a ? document.getelementbyid(a) : a, l.d ? (l.startval = number(n), l.endval = number(t), s(l.startval) && s(l.endval) ? (l.decimals = math.max(0, e || 0), l.dec = math.pow(10, l.decimals), l.duration = 1e3 * number(i) || 2e3, l.countdown = l.startval > l.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.frameval < l.endval ? l.endval : l.frameval : l.frameval = l.frameval > l.endval ? l.endval : l.frameval, l.frameval = math.round(l.frameval * l.dec) / l.dec, l.printvalue(l.frameval), n < l.duration ? l.raf = requestanimationframe(l.count) : l.callback && l.callback() } , l.start = function(a) { l.initialize() && (l.callback = a, l.raf = requestanimationframe(l.count)) } , l.pauseresume = function() { l.paused ? (l.paused = !1, delete l.starttime, l.duration = l.remaining, l.startval = l.frameval, requestanimationframe(l.count)) : (l.paused = !0, cancelanimationframe(l.raf)) } , l.reset = function() { l.paused = !1, delete l.starttime, l.initialized = !1, l.initialize() && (cancelanimationframe(l.raf), l.printvalue(l.startval)) } , l.update = function(a) { if (l.initialize()) { if (a = number(a), !s(a)) return void (l.error = "[countup] update() - new endval is not a number: " + a); l.error = "", a !== l.frameval && (cancelanimationframe(l.raf), l.paused = !1, delete l.starttime, l.startval = l.frameval, l.endval = a, l.countdown = l.startval > l.endval, l.raf = requestanimationframe(l.count)) } } , l.initialize() && l.printvalue(l.startval) }; return e }); function productnumber() { var arr = []; if (typeof (countup) == 'function') { $('#productnumber li').each(function(i, dom) { var idom = $(dom).find('i') , decimals = 0 , sum = idom.data('sum'); sum.tostring().indexof('.') != -1 && (decimals = 1); arr.push(new countup(idom.attr('id'),0,sum,decimals,4,{ useeasing: true, easingfn: null, usegrouping: true, separator: '', decimal: '.' })); arr[i].start(); }); } } $(function() { var win = $(window) , productnumberobj = $('#productnumber') , productnumbertop = productnumberobj.length ? productnumberobj.offset().top : 0 , productnumbertag = false; $(document).on('scroll', function() { if ($(this).scrolltop() + win.height() - 120 > productnumbertop && !productnumbertag) { productnumberobj.length && productnumber(); productnumbertag = true; } }); $(document).trigger('scroll'); });