CountUp.js 实现数字跳转效果的小插件
//调用方法
const easingFn = function (t, b, c, d) {
var ts = (t /= d) * t;
var tc = ts * t;
return b + c * (tc * ts + -5 * ts * ts + 10 * tc + -10 * ts + 5 * t);
}
const options = {
startVal: 5240, //开始时间
duration: 2.1, //动画效果时间
easingFn,
};
let demo = new CountUp('myTargetElement', 60000 //结束时间, options);
if (!demo.error) {
demo.start();
} else {
console.error(demo.error);
}
展示demo地址:http://inorganik.github.io/countUp.js/