CountUp.js 實現數字跳轉效果的小插件javascript
//調用方法java
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/git