Jquery 目标到达时计数减速动画
Jquery Number counting slowdown animation when target reach
$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: 2000,
easing: 'easeOutBack',
step: function (now) {
$(this).html(parseFloat(now).toFixed(2));
},
complete: function () {
}
});
在这个代号运行相同的速度直到结束。我需要数字 运行 到达目标时速度会减慢。
您可以为速度创建一个变量,并随着步长增加。在你的例子中是:
var speed = 2000;
$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: speed,
easing: 'easeOutBack',
step: function (now) {
$(this).html(parseFloat(now).toFixed(2));
if(counter < 1000){
speed += 100;
}
},
complete: function () {
}
});
$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: 2000,
easing: 'easeOutBack',
step: function (now) {
$(this).html(parseFloat(now).toFixed(2));
},
complete: function () {
}
});
在这个代号运行相同的速度直到结束。我需要数字 运行 到达目标时速度会减慢。
您可以为速度创建一个变量,并随着步长增加。在你的例子中是:
var speed = 2000;
$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: speed,
easing: 'easeOutBack',
step: function (now) {
$(this).html(parseFloat(now).toFixed(2));
if(counter < 1000){
speed += 100;
}
},
complete: function () {
}
});