0
我目前正在创建一个简单的游戏,用户尽可能快地点击一个按钮,当用户点击进度条时,应该向用户显示进度,唯一的问题是动画是非常波涛汹涌......有无论如何去平滑动画?流体进度条动画
这里是JSFIDDLE
和JavaScript:
jQuery(document).ready(function(e) {
var $counter = $('#counter');
var $button = $('#lemon-button');
var count = 2;
var speed = 70;
//test for ie7 an ie8
if (!$.support.leadingWhitespace) {
var countAddStep = 5;
//test for ie7 an ie8
}else{
var countAddStep = 3;
}
var timeout;
func = function() {
count--;
$counter.text(count);
if(count <= 4) {
jQuery('.bar').height(400);
}
if(count >= 5) {
jQuery('.bar').height(350);
}
if(count > 6) {
jQuery('.bar').height(300);
}
if(count > 8) {
jQuery('.bar').height(200);
}
if(count > 12) {
jQuery('.bar').height(100);
}
if(count > 14) {
jQuery('.bar').height(20);
}
if(count > 15) {
jQuery('.bar').height(0);
alert("finish");
}
if(count !== 0) {
timeout = setTimeout(func, speed);
}
};
$button.on('click', function() {
count = count+countAddStep;
$counter.text(count);
if (count === countAddStep) {
count++;
func();
}
});
func();
});
任何帮助非常感谢......
作品完美谢谢!只是一个问题,有没有一种方法可以让酒吧在满员之后保持饱满? –
让我试试,我会在找到解决方案后立即在这里发布:-) –
尝试更新的JSFiddle,只要它达到最大值,酒吧就应该保留。 –