1 | (function($) {
|
2 |
|
3 | $.fn.countup = function(params) {
|
4 |
|
5 | if (typeof CountUp !== 'function') {
|
6 | console.error('countUp.js is a required dependency of countUp-jquery.js.');
|
7 | return;
|
8 | }
|
9 |
|
10 | var defaults = {
|
11 | startVal: 0,
|
12 | decimals: 0,
|
13 | duration: 2,
|
14 | };
|
15 |
|
16 | if (typeof params === 'number') {
|
17 | defaults.endVal = params;
|
18 | }
|
19 | else if (typeof params === 'object') {
|
20 | $.extend(defaults, params);
|
21 | }
|
22 | else {
|
23 | console.error('countUp-jquery requires its argument to be either an object or number');
|
24 | return;
|
25 | }
|
26 |
|
27 | this.each(function(i, elem) {
|
28 | var countUp = new CountUp(elem, defaults.startVal, defaults.endVal, defaults.decimals, defaults.duration, defaults.options);
|
29 |
|
30 | countUp.start();
|
31 | });
|
32 |
|
33 |
|
34 |
|
35 | return this;
|
36 |
|
37 | };
|
38 |
|
39 | }(jQuery)); |
\ | No newline at end of file |