diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..937d520 --- /dev/null +++ b/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": [ + ["env", { "modules": false }], + "stage-2", + "es2015" + ], + "plugins": [ + "transform-runtime" + ], + "comments": false +} diff --git a/README.md b/README.md index d6c243f..f3a4589 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ Odometer ======== +``` +// 打包命令 + +npm run build +``` + Odometer is a Javascript and CSS library for smoothly transitioning numbers. ### [Overview](http://github.hubspot.com/odometer/docs/welcome) diff --git a/build/webpack.base.config.js b/build/webpack.base.config.js new file mode 100644 index 0000000..ee2bf5f --- /dev/null +++ b/build/webpack.base.config.js @@ -0,0 +1,15 @@ +/** + * 公共配置 + */ +module.exports = { + // 加载器 + module: { + rules: [ + { + test: /\.js$/, + loader: ['babel-loader'], + exclude: /(node_modules)/ + } + ] + } +}; diff --git a/build/webpack.config.js b/build/webpack.config.js new file mode 100644 index 0000000..1545031 --- /dev/null +++ b/build/webpack.config.js @@ -0,0 +1,37 @@ +const path = require('path'); +const webpack = require('webpack'); +const merge = require('webpack-merge') +const webpackBaseConfig = require('./webpack.base.config.js'); +const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin') + +process.env.NODE_ENV = 'production' + +module.exports = merge(webpackBaseConfig, { + entry: { + main: './odometer.js' + }, + output: { + path: path.resolve(__dirname, '../'), + filename: 'odometer.min.js', + library: 'odometer', + libraryTarget: 'umd', + umdNamedDefine: true + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: '"production"' + } + }), + new ParallelUglifyPlugin({ + uglifyJS:{ + output: { + comments: false + }, + compress: { + warnings: false + } + } + }) + ] +}); diff --git a/odometer.js b/odometer.js index d66b4ed..001903b 100644 --- a/odometer.js +++ b/odometer.js @@ -1,12 +1,12 @@ (function() { - var COUNT_FRAMERATE, COUNT_MS_PER_FRAME, DIGIT_FORMAT, DIGIT_HTML, DIGIT_SPEEDBOOST, DURATION, FORMAT_MARK_HTML, FORMAT_PARSER, FRAMERATE, FRAMES_PER_VALUE, MS_PER_FRAME, MutationObserver, Odometer, RIBBON_HTML, TRANSITION_END_EVENTS, TRANSITION_SUPPORT, VALUE_HTML, addClass, createFromHTML, fractionalPart, now, removeClass, requestAnimationFrame, round, transitionCheckStyles, trigger, truncate, wrapJQuery, _jQueryWrapped, _old, _ref, _ref1, + var MIN_INTEGER_LEN, COUNT_FRAMERATE, COUNT_MS_PER_FRAME, DIGIT_FORMAT, DIGIT_HTML, DIGIT_SPEEDBOOST, DURATION, FORMAT_MARK_HTML, FORMAT_PARSER, FRAMERATE, FRAMES_PER_VALUE, MS_PER_FRAME, MutationObserver, Odometer, PLACEHOLDER_DIGIT, RIBBON_HTML, TRANSITION_END_EVENTS, TRANSITION_SUPPORT, VALUE_HTML, addClass, createFromHTML, fractionalPart, now, removeClass, requestAnimationFrame, round, transitionCheckStyles, trigger, truncate, wrapJQuery, _jQueryWrapped, _old, _ref, _ref1, __slice = [].slice; VALUE_HTML = ''; RIBBON_HTML = '' + VALUE_HTML + ''; - DIGIT_HTML = '8' + RIBBON_HTML + ''; + DIGIT_HTML = '' + RIBBON_HTML + ''; FORMAT_MARK_HTML = ''; @@ -24,10 +24,14 @@ DIGIT_SPEEDBOOST = .5; + MIN_INTEGER_LEN = 12; + MS_PER_FRAME = 1000 / FRAMERATE; COUNT_MS_PER_FRAME = 1000 / COUNT_FRAMERATE; + PLACEHOLDER_DIGIT = '8'; + TRANSITION_END_EVENTS = 'transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd'; transitionCheckStyles = document.createElement('div').style; @@ -144,6 +148,12 @@ if ((_base = this.options).duration == null) { _base.duration = DURATION; } + + MIN_INTEGER_LEN = this.options.numberLength || MIN_INTEGER_LEN; + + // need to allow this to be 0 + PLACEHOLDER_DIGIT = this.options.placeholderDigit !== undefined ? this.options.placeholderDigit.toString() : PLACEHOLDER_DIGIT; + this.MAX_VALUES = ((this.options.duration / MS_PER_FRAME) / FRAMES_PER_VALUE) | 0; this.resetFormat(); this.value = this.cleanValue((_ref1 = this.options.value) != null ? _ref1 : ''); @@ -278,7 +288,7 @@ }; Odometer.prototype.render = function(value) { - var classes, cls, match, newClasses, theme, _i, _len; + var classes, cls, digit, match, newClasses, theme, wholePart, _i, _j, _len, _len1, _ref; if (value == null) { value = this.value; } @@ -313,38 +323,37 @@ } this.el.className = newClasses.join(' '); this.ribbons = {}; - this.formatDigits(value); - return this.startWatchingMutations(); - }; - - Odometer.prototype.formatDigits = function(value) { - var digit, valueDigit, valueString, wholePart, _i, _j, _len, _len1, _ref, _ref1; this.digits = []; - if (this.options.formatFunction) { - valueString = this.options.formatFunction(value); - _ref = valueString.split('').reverse(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - valueDigit = _ref[_i]; - if (valueDigit.match(/0-9/)) { - digit = this.renderDigit(); - digit.querySelector('.odometer-value').innerHTML = valueDigit; - this.digits.push(digit); - this.insertDigit(digit); - } else { - this.addSpacer(valueDigit); - } + wholePart = !this.format.precision || !fractionalPart(value) || false; + _ref = value.toString().split('').reverse(); + + /** + * todo 解决补零动画问题开始 + * + * _allref 替换了 _ref字段 + */ + var _newref = []; + var _allref = []; + + if(_ref.length < MIN_INTEGER_LEN){ + for(let i = 0; i< MIN_INTEGER_LEN - _ref.length; i++){ + _newref.push('0') } - } else { - wholePart = !this.format.precision || !fractionalPart(value) || false; - _ref1 = value.toString().split('').reverse(); - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - digit = _ref1[_j]; - if (digit === '.') { - wholePart = true; - } - this.addDigit(digit, wholePart); + } + _allref = _ref.concat(_newref); + /** + * todo 解决补零动画问题结束 + * + */ + + for (_j = 0, _len1 = _allref.length; _j < _len1; _j++) { + digit = _allref[_j]; + if (digit === '.') { + wholePart = true; } + this.addDigit(digit, wholePart); } + return this.startWatchingMutations(); }; Odometer.prototype.update = function(newValue) { @@ -424,7 +433,14 @@ } } digit = this.renderDigit(); + digit.querySelector('.odometer-digit-spacer').innerHTML = PLACEHOLDER_DIGIT; digit.querySelector('.odometer-value').innerHTML = value; + + /** + * todo + */ + digit.setAttribute("name", 'digit'+value) + this.digits.push(digit); return this.insertDigit(digit); }; @@ -519,9 +535,14 @@ digitCount = this.getDigitCount(oldValue, newValue); digits = []; boosted = 0; - for (i = _i = 0; 0 <= digitCount ? _i < digitCount : _i > digitCount; i = 0 <= digitCount ? ++_i : --_i) { - start = truncate(oldValue / Math.pow(10, digitCount - i - 1)); - end = truncate(newValue / Math.pow(10, digitCount - i - 1)); + /** + * todo 解决补零动画问题 + * + * MIN_INTEGER_LEN 替换了 digitCount字段 + */ + for (i = _i = 0; 0 <= MIN_INTEGER_LEN ? _i < MIN_INTEGER_LEN : _i > MIN_INTEGER_LEN; i = 0 <= MIN_INTEGER_LEN ? ++_i : --_i) { + start = truncate(oldValue / Math.pow(10, MIN_INTEGER_LEN - i - 1)); + end = truncate(newValue / Math.pow(10, MIN_INTEGER_LEN - i - 1)); dist = end - start; if (Math.abs(dist) > this.MAX_VALUES) { frames = []; @@ -538,7 +559,7 @@ } else { frames = (function() { _results = []; - for (var _j = start; start <= end ? _j <= end : _j >= end; start <= end ? _j++ : _j--){ _results.push(_j); } + for (var _j = start; start <= end ? _j <= end : _j >= end; start <= end ? _j++ : _j--) { _results.push(_j); } return _results; }).apply(this); } diff --git a/odometer.min.js b/odometer.min.js index 48da2e9..8247265 100644 --- a/odometer.min.js +++ b/odometer.min.js @@ -1,2 +1 @@ -/*! odometer 0.4.8 */ -(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G=[].slice;q='',n=''+q+"",d='8'+n+"",g='',c="(,ddd).dd",h=/^\(?([^)]*)\)?(?:(.)(d+))?$/,i=30,f=2e3,a=20,j=2,e=.5,k=1e3/i,b=1e3/a,o="transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",y=document.createElement("div").style,p=null!=y.transition||null!=y.webkitTransition||null!=y.mozTransition||null!=y.oTransition,w=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,l=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,s=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.children[0]},v=function(a,b){return a.className=a.className.replace(new RegExp("(^| )"+b.split(" ").join("|")+"( |$)","gi")," ")},r=function(a,b){return v(a,b),a.className+=" "+b},z=function(a,b){var c;return null!=document.createEvent?(c=document.createEvent("HTMLEvents"),c.initEvent(b,!0,!0),a.dispatchEvent(c)):void 0},u=function(){var a,b;return null!=(a=null!=(b=window.performance)&&"function"==typeof b.now?b.now():void 0)?a:+new Date},x=function(a,b){return null==b&&(b=0),b?(a*=Math.pow(10,b),a+=.5,a=Math.floor(a),a/=Math.pow(10,b)):Math.round(a)},A=function(a){return 0>a?Math.ceil(a):Math.floor(a)},t=function(a){return a-x(a)},C=!1,(B=function(){var a,b,c,d,e;if(!C&&null!=window.jQuery){for(C=!0,d=["html","text"],e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(function(a){var b;return b=window.jQuery.fn[a],window.jQuery.fn[a]=function(a){var c;return null==a||null==(null!=(c=this[0])?c.odometer:void 0)?b.apply(this,arguments):this[0].odometer.update(a)}}(a));return e}})(),setTimeout(B,0),m=function(){function a(b){var c,d,e,g,h,i,l,m,n,o,p=this;if(this.options=b,this.el=this.options.el,null!=this.el.odometer)return this.el.odometer;this.el.odometer=this,m=a.options;for(d in m)g=m[d],null==this.options[d]&&(this.options[d]=g);null==(h=this.options).duration&&(h.duration=f),this.MAX_VALUES=this.options.duration/k/j|0,this.resetFormat(),this.value=this.cleanValue(null!=(n=this.options.value)?n:""),this.renderInside(),this.render();try{for(o=["innerHTML","innerText","textContent"],i=0,l=o.length;l>i;i++)e=o[i],null!=this.el[e]&&!function(a){return Object.defineProperty(p.el,a,{get:function(){var b;return"innerHTML"===a?p.inside.outerHTML:null!=(b=p.inside.innerText)?b:p.inside.textContent},set:function(a){return p.update(a)}})}(e)}catch(q){c=q,this.watchForMutations()}}return a.prototype.renderInside=function(){return this.inside=document.createElement("div"),this.inside.className="odometer-inside",this.el.innerHTML="",this.el.appendChild(this.inside)},a.prototype.watchForMutations=function(){var a,b=this;if(null!=l)try{return null==this.observer&&(this.observer=new l(function(a){var c;return c=b.el.innerText,b.renderInside(),b.render(b.value),b.update(c)})),this.watchMutations=!0,this.startWatchingMutations()}catch(c){a=c}},a.prototype.startWatchingMutations=function(){return this.watchMutations?this.observer.observe(this.el,{childList:!0}):void 0},a.prototype.stopWatchingMutations=function(){var a;return null!=(a=this.observer)?a.disconnect():void 0},a.prototype.cleanValue=function(a){var b;return"string"==typeof a&&(a=a.replace(null!=(b=this.format.radix)?b:".",""),a=a.replace(/[.,]/g,""),a=a.replace("","."),a=parseFloat(a,10)||0),x(a,this.format.precision)},a.prototype.bindTransitionEnd=function(){var a,b,c,d,e,f,g=this;if(!this.transitionEndBound){for(this.transitionEndBound=!0,b=!1,e=o.split(" "),f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(this.el.addEventListener(a,function(){return b?!0:(b=!0,setTimeout(function(){return g.render(),b=!1,z(g.el,"odometerdone")},0),!0)},!1));return f}},a.prototype.resetFormat=function(){var a,b,d,e,f,g,i,j;if(a=null!=(i=this.options.format)?i:c,a||(a="d"),d=h.exec(a),!d)throw new Error("Odometer: Unparsable digit format");return j=d.slice(1,4),g=j[0],f=j[1],b=j[2],e=(null!=b?b.length:void 0)||0,this.format={repeating:g,radix:f,precision:e}},a.prototype.render=function(a){var b,c,d,e,f,g,h;for(null==a&&(a=this.value),this.stopWatchingMutations(),this.resetFormat(),this.inside.innerHTML="",f=this.options.theme,b=this.el.className.split(" "),e=[],g=0,h=b.length;h>g;g++)c=b[g],c.length&&((d=/^odometer-theme-(.+)$/.exec(c))?f=d[1]:/^odometer(-|$)/.test(c)||e.push(c));return e.push("odometer"),p||e.push("odometer-no-transitions"),f?e.push("odometer-theme-"+f):e.push("odometer-auto-theme"),this.el.className=e.join(" "),this.ribbons={},this.formatDigits(a),this.startWatchingMutations()},a.prototype.formatDigits=function(a){var b,c,d,e,f,g,h,i,j,k;if(this.digits=[],this.options.formatFunction)for(d=this.options.formatFunction(a),j=d.split("").reverse(),f=0,h=j.length;h>f;f++)c=j[f],c.match(/0-9/)?(b=this.renderDigit(),b.querySelector(".odometer-value").innerHTML=c,this.digits.push(b),this.insertDigit(b)):this.addSpacer(c);else for(e=!this.format.precision||!t(a)||!1,k=a.toString().split("").reverse(),g=0,i=k.length;i>g;g++)b=k[g],"."===b&&(e=!0),this.addDigit(b,e)},a.prototype.update=function(a){var b,c=this;return a=this.cleanValue(a),(b=a-this.value)?(v(this.el,"odometer-animating-up odometer-animating-down odometer-animating"),b>0?r(this.el,"odometer-animating-up"):r(this.el,"odometer-animating-down"),this.stopWatchingMutations(),this.animate(a),this.startWatchingMutations(),setTimeout(function(){return c.el.offsetHeight,r(c.el,"odometer-animating")},0),this.value=a):void 0},a.prototype.renderDigit=function(){return s(d)},a.prototype.insertDigit=function(a,b){return null!=b?this.inside.insertBefore(a,b):this.inside.children.length?this.inside.insertBefore(a,this.inside.children[0]):this.inside.appendChild(a)},a.prototype.addSpacer=function(a,b,c){var d;return d=s(g),d.innerHTML=a,c&&r(d,c),this.insertDigit(d,b)},a.prototype.addDigit=function(a,b){var c,d,e,f;if(null==b&&(b=!0),"-"===a)return this.addSpacer(a,null,"odometer-negation-mark");if("."===a)return this.addSpacer(null!=(f=this.format.radix)?f:".",null,"odometer-radix-mark");if(b)for(e=!1;;){if(!this.format.repeating.length){if(e)throw new Error("Bad odometer format without digits");this.resetFormat(),e=!0}if(c=this.format.repeating[this.format.repeating.length-1],this.format.repeating=this.format.repeating.substring(0,this.format.repeating.length-1),"d"===c)break;this.addSpacer(c)}return d=this.renderDigit(),d.querySelector(".odometer-value").innerHTML=a,this.digits.push(d),this.insertDigit(d)},a.prototype.animate=function(a){return p&&"count"!==this.options.animation?this.animateSlide(a):this.animateCount(a)},a.prototype.animateCount=function(a){var c,d,e,f,g,h=this;if(d=+a-this.value)return f=e=u(),c=this.value,(g=function(){var i,j,k;return u()-f>h.options.duration?(h.value=a,h.render(),void z(h.el,"odometerdone")):(i=u()-e,i>b&&(e=u(),k=i/h.options.duration,j=d*k,c+=j,h.render(Math.round(c))),null!=w?w(g):setTimeout(g,b))})()},a.prototype.getDigitCount=function(){var a,b,c,d,e,f;for(d=1<=arguments.length?G.call(arguments,0):[],a=e=0,f=d.length;f>e;a=++e)c=d[a],d[a]=Math.abs(c);return b=Math.max.apply(Math,d),Math.ceil(Math.log(b+1)/Math.log(10))},a.prototype.getFractionalDigitCount=function(){var a,b,c,d,e,f,g;for(e=1<=arguments.length?G.call(arguments,0):[],b=/^\-?\d*\.(\d*?)0*$/,a=f=0,g=e.length;g>f;a=++f)d=e[a],e[a]=d.toString(),c=b.exec(e[a]),null==c?e[a]=0:e[a]=c[1].length;return Math.max.apply(Math,e)},a.prototype.resetDigits=function(){return this.digits=[],this.ribbons=[],this.inside.innerHTML="",this.resetFormat()},a.prototype.animateSlide=function(a){var b,c,d,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z,B,C,D,E;if(s=this.value,j=this.getFractionalDigitCount(s,a),j&&(a*=Math.pow(10,j),s*=Math.pow(10,j)),d=a-s){for(this.bindTransitionEnd(),f=this.getDigitCount(s,a),g=[],b=0,m=v=0;f>=0?f>v:v>f;m=f>=0?++v:--v){if(t=A(s/Math.pow(10,f-m-1)),i=A(a/Math.pow(10,f-m-1)),h=i-t,Math.abs(h)>this.MAX_VALUES){for(l=[],n=h/(this.MAX_VALUES+this.MAX_VALUES*b*e),c=t;h>0&&i>c||0>h&&c>i;)l.push(Math.round(c)),c+=n;l[l.length-1]!==i&&l.push(i),b++}else l=function(){E=[];for(var a=t;i>=t?i>=a:a>=i;i>=t?a++:a--)E.push(a);return E}.apply(this);for(m=w=0,y=l.length;y>w;m=++w)k=l[m],l[m]=Math.abs(k%10);g.push(l)}for(this.resetDigits(),D=g.reverse(),m=x=0,z=D.length;z>x;m=++x)for(l=D[m],this.digits[m]||this.addDigit(" ",m>=j),null==(u=this.ribbons)[m]&&(u[m]=this.digits[m].querySelector(".odometer-ribbon-inner")),this.ribbons[m].innerHTML="",0>d&&(l=l.reverse()),o=C=0,B=l.length;B>C;o=++C)k=l[o],q=document.createElement("div"),q.className="odometer-value",q.innerHTML=k,this.ribbons[m].appendChild(q),o===l.length-1&&r(q,"odometer-last-value"),0===o&&r(q,"odometer-first-value");return 0>t&&this.addDigit("-"),p=this.inside.querySelector(".odometer-radix-mark"),null!=p&&p.parent.removeChild(p),j?this.addSpacer(this.format.radix,this.digits[j-1],"odometer-radix-mark"):void 0}},a}(),m.options=null!=(E=window.odometerOptions)?E:{},setTimeout(function(){var a,b,c,d,e;if(window.odometerOptions){d=window.odometerOptions,e=[];for(a in d)b=d[a],e.push(null!=(c=m.options)[a]?(c=m.options)[a]:c[a]=b);return e}},0),m.init=function(){var a,b,c,d,e,f;if(null!=document.querySelectorAll){for(b=document.querySelectorAll(m.options.selector||".odometer"),f=[],c=0,d=b.length;d>c;c++)a=b[c],f.push(a.odometer=new m({el:a,value:null!=(e=a.innerText)?e:a.textContent}));return f}},null!=(null!=(F=document.documentElement)?F.doScroll:void 0)&&null!=document.createEventObject?(D=document.onreadystatechange,document.onreadystatechange=function(){return"complete"===document.readyState&&m.options.auto!==!1&&m.init(),null!=D?D.apply(this,arguments):void 0}):document.addEventListener("DOMContentLoaded",function(){return m.options.auto!==!1?m.init():void 0},!1),"function"==typeof define&&define.amd?define([],function(){return m}):"undefined"!=typeof exports&&null!==exports?module.exports=m:window.Odometer=m}).call(this); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("odometer",[],e):"object"==typeof exports?exports.odometer=e():t.odometer=e()}(this,function(){return function(n){var i={};function r(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=i,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e,n){t.exports=!n(5)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=n)},function(t,e,n){var i=n(14),r=n(15),o=n(17),s=Object.defineProperty;e.f=n(0)?Object.defineProperty:function(t,e,n){if(i(t),e=o(e,!0),i(n),r)try{return s(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(w,M,t){"use strict";var b,e,n=t(7),x=(e=n)&&e.__esModule?e:{default:e};(function(){var j,u,t,s,h,v,O,r,g,l,i,c,n,e,f,D,o,a,d,p,m,y=[].slice;u=/^\(?([^)]*)\)?(?:(.)(d+))?$/,j=12,h="8",e=document.createElement("div").style,v=null!=e.transition||null!=e.webkitTransition||null!=e.mozTransition||null!=e.oTransition,c=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,t=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,r=function(t){var e;return(e=document.createElement("div")).innerHTML=t,e.children[0]},i=function(t,e){return t.className=t.className.replace(new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi")," ")},O=function(t,e){return i(t,e),t.className+=" "+e},f=function(t,e){var n;if(null!=document.createEvent)return(n=document.createEvent("HTMLEvents")).initEvent(e,!0,!0),t.dispatchEvent(n)},l=function(){var t,e;return null!=(t=null!=(e=window.performance)&&"function"==typeof e.now?e.now():void 0)?t:+new Date},n=function(t,e){return null==e&&(e=0),e?(t*=Math.pow(10,e),t+=.5,(t=Math.floor(t))/Math.pow(10,e)):Math.round(t)},D=function(t){return t<0?Math.ceil(t):Math.floor(t)},a=!(g=function(t){return t-n(t)}),(o=function(){var t,e,n,i,r;if(!a&&null!=window.jQuery){for(a=!0,r=[],e=0,n=(i=["html","text"]).length;e")).replace(/[.,]/g,"")).replace("","."),t=parseFloat(t,10)||0),n(t,this.format.precision)},d.prototype.bindTransitionEnd=function(){var t,e,n,i,r,o,s=this;if(!this.transitionEndBound){for(this.transitionEndBound=!0,e=!1,o=[],n=0,i=(r="transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd".split(" ")).length;n')},d.prototype.insertDigit=function(t,e){return null!=e?this.inside.insertBefore(t,e):this.inside.children.length?this.inside.insertBefore(t,this.inside.children[0]):this.inside.appendChild(t)},d.prototype.addSpacer=function(t,e,n){var i;return(i=r('')).innerHTML=t,n&&O(i,n),this.insertDigit(i,e)},d.prototype.addDigit=function(t,e){var n,i,r,o;if(null==e&&(e=!0),"-"===t)return this.addSpacer(t,null,"odometer-negation-mark");if("."===t)return this.addSpacer(null!=(o=this.format.radix)?o:".",null,"odometer-radix-mark");if(e)for(r=!1;;){if(!this.format.repeating.length){if(r)throw new Error("Bad odometer format without digits");this.resetFormat(),r=!0}if(n=this.format.repeating[this.format.repeating.length-1],this.format.repeating=this.format.repeating.substring(0,this.format.repeating.length-1),"d"===n)break;this.addSpacer(n)}return(i=this.renderDigit()).querySelector(".odometer-digit-spacer").innerHTML=h,i.querySelector(".odometer-value").innerHTML=t,i.setAttribute("name","digit"+t),this.digits.push(i),this.insertDigit(i)},d.prototype.animate=function(t){return v&&"count"!==this.options.animation?this.animateSlide(t):this.animateCount(t)},d.prototype.animateCount=function(n){var i,r,o,s,a,u=this;if(r=+n-this.value)return s=o=l(),i=this.value,(a=function(){var t,e;return l()-s>u.options.duration?(u.value=n,u.render(),void f(u.el,"odometerdone")):(50<(t=l()-o)&&(o=l(),e=t/u.options.duration,i+=r*e,u.render(Math.round(i))),null!=c?c(a):setTimeout(a,50))})()},d.prototype.getDigitCount=function(){var t,e,n,i,r,o;for(t=r=0,o=(i=1<=arguments.length?y.call(arguments,0):[]).length;rthis.MAX_VALUES){for(l=[],d=o/(this.MAX_VALUES+this.MAX_VALUES*e*.5),n=v;0", - "Zack Bloom " + "Zack Bloom ", + "wangqi " ], + "scripts": { + "build": "webpack --config build/webpack.config.js" + }, "license": "MIT", "devDependencies": { - "grunt-contrib-coffee": "~0.7.0", + "babel-core": "^6.26.3", + "babel-loader": "^7.1.4", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-env": "^1.7.0", + "babel-preset-es2015": "^6.24.1", + "babel-preset-stage-2": "^6.24.1", "coffee-script": "~1.6.3", - "grunt-contrib-uglify": "~0.2.4", - "grunt-cli": "~0.1.9", + "color": "~0.4.4", "grunt": "~0.4.1", - "grunt-contrib-watch": "~0.5.3", + "grunt-cli": "~0.1.9", + "grunt-contrib-coffee": "~0.7.0", "grunt-contrib-compass": "~0.5.0", - "color": "~0.4.4" + "grunt-contrib-uglify": "~0.2.4", + "grunt-contrib-watch": "~0.5.3", + "webpack": "^3.5.1", + "webpack-merge": "^4.1.3", + "webpack-parallel-uglify-plugin": "^1.1.0" } } diff --git a/test/demo.html b/test/demo.html index 860724b..d0bfd74 100644 --- a/test/demo.html +++ b/test/demo.html @@ -11,8 +11,8 @@ }; - - + +
3252
+