首页 > Web开发 > 详细

JS 数字快速跳动

时间:2019-05-28 16:15:13      阅读:181      评论:0      收藏:0      [点我收藏+]

!
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);

JS 数字快速跳动

原文:https://www.cnblogs.com/noonka/p/10937982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!