jQuery Animation() - 太快完成触发
我写了一个小动画脚本,从左到右淡化一组条纹。所有动画完成后,应运行回调函数。
脚本在这里:
它工作正常,但我想做从右到左的动画也是如此:
你可以看到回调函数在动画结束之前被触发:( 我唯一改变的是延迟()。我在这里做错了什么?为什么“完整”在所有动画完成之前运行?
I wrote a little animation script that fades a set of stripes from left to right. After all animations are complete a callback functions shoud run.
The script is here:
It works fine, but I want to do the same for a right-to-left animation:
As you can see the callback function is fired before animation ends :(
The only thing I changed is the delay()
. What am I doing wrong here? Why is "complete" running before all animations finish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你快到了,你确实扭转了方向,但忘记了回调也解释了逆转。这样做对我有用:
因为你正在计算另一个方向,如果你尝试在 cols - 1 处检查完成,你会太早得到它,你需要在这里得到 0 。试试这个:http://jsfiddle.net/FTrhX/8/
You are almost there, you did reverse the direction, but forgot on the callback to also account for the reversal. Doing this works for me:
Because you are counting the other direction if you try and check complete at cols - 1 you'll get it too early, you need to get it at 0 here. try this one: http://jsfiddle.net/FTrhX/8/
我看了你的两个预览,给我留下了深刻的印象!虽然我不明白为什么第二个函数需要
.stop()
。这种方式也很好用,还是我错过了什么?
I looked at both your previews and I am really impressed! Though I don't understand why
.stop()
is needed in the second function.This way works fine too, or am I missing something?