[英]jquery animate doesn't work properly
When I use jQuery .animate()
with a bootstrap progress bar to set progress percentages, it only works normal the first time I use it. 当我使用带有引导进度条的jQuery
.animate()
来设置进度百分比时,它只在我第一次使用它时才能正常工作。 I've made a JSFiddle here: http://jsfiddle.net/43bqP/ 我在这里做了一个JSFiddle: http : //jsfiddle.net/43bqP/
When it just had to go to 50, it somehow first goes above 500 and then animates back to 50. How can I fix this? 当它只需要达到50时,它首先会超过500,然后动画回到50.如何解决这个问题?
The problem is due to 问题是由于
duration : pauseBetweenSteps / 2
and the alert()
method called when all the steps have been executed, but the animation is still in act. 并且在执行了所有步骤时调用了
alert()
方法,但动画仍处于动作状态。
I'm not sure to understand why you're setting duration
like this. 我不确定你为什么设置这样的
duration
。 Try leaving the default (400) by unsetting it, and add a setTimeout
by 500ms around the alert("done")
, to be sure the animation has ended. 尝试通过取消设置保留默认值(400),并在
alert("done")
周围添加500ms的setTimeout
,以确保动画已结束。
Working eg. 工作例如。 http://jsfiddle.net/eEE87/
http://jsfiddle.net/eEE87/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.