功能完成后检查 [英] Check once a function is complete
问题描述
单击链接以赋予漫画风格效果时,我加载的div的偏移量很小.每个偏移量都会激活其他动画,以提供更动态的感觉.
I have a lit of offsets for a div that I load when a link is clicked to give a comic book style effect. Each offset activates other animations to give a more dynamic feel.
我现在正在寻求对其进行更改,以便从偏移量0偏移到偏移量2将通过偏移量1移动.要增加复杂性,我不希望在这种情况下关闭偏移量1的辅助动画.
I am now looking to change it so that to move from offset 0 to offset 2 will move via offset 1. To add to the complexity, I don't want the secondary animations at offset 1 to go off in this instance.
因此,问题是我需要激活滑动功能,然后在当前功能完成后再次激活它.有什么办法让我知道吗?另外,是否有一种简单的方法可以反转动画,以便动画在下次到达该偏移时发生?
The problem, therefore, is that I need to activate the sliding function and then activate it again once the current one is complete. Is there a way for me to know this? Also, is there an easy way to reverse the animation so it will occur the next time they go to that offset?
如果我使用错误的方法,请随时告诉我.
If I am going about this the wrong way, please feel free to tell me.
推荐答案
看来,您问题的核心是javascript代码流.您将要使用回调函数.如果您向函数添加回调变量,则可以在函数运行其过程之后执行代码:
It seems that the core of your problem is the flow of the javascript code. You will want to use a callback function. If you add a callback variable to a function, you can execute code after the function has run its course:
function foo(callback) {
// some code you want to execute
// then run the callback function
if (typeof(callback) == "function")
callback();
}
function bar() {
// some code you want to execute after foo is finished
}
现在,您可以在foo完成后像这样运行bar()
:
Now you can run bar()
after foo is complete like this:
foo(bar);
这篇关于功能完成后检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!