forked from albamaruo/gift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb1.js.ダウンロード
61 lines (59 loc) · 2.03 KB
/
web1.js.ダウンロード
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(function(a) {
a.fn.countTo = function(b) {
b = b || {};
return a(this).each(function() {
function d(a) {
a = c.formatter.call(k, a, c);
h.html(a)
}
var c = a.extend({}, a.fn.countTo.defaults, {
from: a(this).data("from"),
to: a(this).data("to"),
speed: a(this).data("speed"),
refreshInterval: a(this).data("refresh-interval"),
decimals: a(this).data("decimals")
}, b),
l = Math.ceil(c.speed / c.refreshInterval),
n = (c.to - c.from) / l,
k = this,
h = a(this),
m = 0,
f = c.from,
g = h.data("countTo") || {};
h.data("countTo", g);
g.interval && clearInterval(g.interval);
g.interval = setInterval(function() {
f += n;
m++;
d(f);
"function" == typeof c.onUpdate && c.onUpdate.call(k, f);
m >= l && (h.removeData("countTo"), clearInterval(g.interval), f = c.to, "function" == typeof c.onComplete && c.onComplete.call(k, f))
}, c.refreshInterval);
d(f)
})
};
a.fn.countTo.defaults = {
from: 0,
to: 0,
speed: 100,
refreshInterval: 100,
decimals: 0,
formatter: function(a, d) {
return a.toFixed(d.decimals)
},
onUpdate: null,
onComplete: null
}
})(jQuery);
jQuery(function(a) {
a(".count-number").data("countToOptions", {
formatter: function(a, d) {
return a.toFixed(d.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ",")
}
});
a(".timer").each(function(b) {
var d = a(this);
b = a.extend({}, b || {}, d.data("countToOptions") || {});
d.countTo(b)
})
});