JS 数字快速跳动


!
function(e) {
var t = [],
i = function(e, i) {
i = i || {};
var n = !1;
if ($.each(t,
function(t, i) {
this == e && (n = !0)
}), n) return ! 1;
t.push(e);
var o, a, s = $(e),
l = 1e3 * (i.time || s.data("time")),
r = i.num || s.data("value"),
h = +new Date,
c = function(e) {
var t = [],
i = 0;
e = (e || 0).toString().split("");
for (var n = e.length - 1; n >= 0; n--) i++,
t.unshift(e[n]),
i % 3 || 0 == n || t.unshift(",");
return t.join("")
};
a = setInterval(function() {
o = +new Date;
var e = o - h,
t = r * (e / l);
e >= l ? (t = r, clearInterval(a)) : t = Math.floor(t),
s.text(c(t) + "+")
},
16)
},
n = function() {
var e = [];
return $.each($(".runtime"),
function(t, i) {
e.push({
el: this,
offsetTop: $(this).offset().top,
offsetEndTop: $(this).height() + $(this).offset().top
})
}),
e
} (),
o = 0,
a = function() {
var e = $(window).scrollTop() + .8 * $(window).height();
$.each(n,
function(t, a) {
e > a.offsetTop && e < a.offsetEndTop + .8 * $(window).height() && !$(a.el).hasClass("active") && (o++, $(a.el).addClass("active"), 0 != $(a.el).find("*[number]").length && $.each($(a.el).find("*[number]"),
function() {
i(this)
}), n.length == o && clearInterval(s))
})
},
s = setInterval(function() {
a()
},
100);
a();
 
} (window);
posted @ 2019-05-28 16:01  noonka  阅读(1271)  评论(0编辑  收藏  举报