mootools 中的延迟或 setInterval
早上好,
我在使用 mootools 时遇到了问题,我制作了一个从 0 到 100 的 alpha 效果,但我想在加载下一个效果之前进行延迟。
代码如下:
<script type="text/javascript">
var miEfecto1 = new Fx.Style('texto42' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto2.start(1,0) , 15000 );}});
var miEfecto2 = new Fx.Style('texto14' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto3.start(1,0) , 15000 );}});
...etc...
var miEfecto59 = new Fx.Style('texto45' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto60.start(1,0) , 15000 );}});
var miEfecto60 = new Fx.Style('texto39' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto61.start(1,0) , 15000 );}});
window.addEvent('domready',function() {
miEfecto1.start(1,0);});
</script>
非常感谢您的帮助!
Good morning,
I have a problem with mootools, and I make an alpha effect from 0 to 100 but I would like to make a delay before loading the next effect.
code is as follows:
<script type="text/javascript">
var miEfecto1 = new Fx.Style('texto42' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto2.start(1,0) , 15000 );}});
var miEfecto2 = new Fx.Style('texto14' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto3.start(1,0) , 15000 );}});
...etc...
var miEfecto59 = new Fx.Style('texto45' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto60.start(1,0) , 15000 );}});
var miEfecto60 = new Fx.Style('texto39' ,'opacity',{duration: 9000,onComplete: function(){setInterval(miEfecto61.start(1,0) , 15000 );}});
window.addEvent('domready',function() {
miEfecto1.start(1,0);});
</script>
thank you very much for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
setInterval
为作为第一个参数传递的某些函数设置间隔,其中setTimeout
只是延迟执行。 使用后者以避免多次执行。另外,在您的代码中,您立即执行
start()
方法(例如miEfecto2.start(1,0)
),因为您没有通过it - 你传递了它的结果。要解决此问题,您可以将其包含在匿名函数中(但不要调用它)。示例代码可能如下所示(请注意
setInterval
被setTimeout
替换,并且我将函数调用包含在匿名函数中):在代码的其余部分中进行类似的更改。
setInterval
sets interval for some function you pass as the first parameter, wheresetTimeout
just delays the execution. Use the latter to avoid multiple execution.Also in your code you immediately execute
start()
method (eg.miEfecto2.start(1,0)
), because you do not pass it - you pass its result. To fix this you can enclose it in an anonymous function (but do not call it).The example code could look like this (notice
setInterval
being replaced bysetTimeout
and that I enclosed the function call in anonymous function):Make similar changes in the rest of your code.
您需要做的就是链接效果并将延迟设置为您需要的任何内容。
检查此示例: http:// /demos111.mootools.net/Chain
或查看文档:http://mootools.net/docs/core/Class/Class.Extras
希望这有帮助
what you need to do is to chain the effects and set the delay to whatever you need..
check this example : http://demos111.mootools.net/Chain
or check the doc : http://mootools.net/docs/core/Class/Class.Extras
Hope this helps
解决方案:
谢谢!!
THE SOLUTION:
THANKS!!