是否有一些 dojo.fx.sleep 函数可以在 dojo.fx.chain 动画中使用?
我想在一秒钟内淡入
一个节点。 然后保持 10 秒钟。 然后再淡出
3 秒。 链接它的一种方法如下:
dojo.fx.chain([
dojo.fadeIn({node:myNode, duration:1000}), // fading in for 1 second
dojo.fadeIn({node:myNode, duration:10000}), // this does nothing for 10 seconds
dojo.fadeOut({node:myNode, duration:3000}) // fade out for 3 seconds
]).play();
在前面的代码中,中间步骤是一种非常愚蠢的方法,一无所获。 是否有某种在指定时间长度内不执行任何操作的 dojo.fx.sleep 动画?
I would like to fadeIn
a node over one second. Then leave it on for 10 seconds. Then fadeOut
for another 3 seconds. One way of chaining this would be as follows:
dojo.fx.chain([
dojo.fadeIn({node:myNode, duration:1000}), // fading in for 1 second
dojo.fadeIn({node:myNode, duration:10000}), // this does nothing for 10 seconds
dojo.fadeOut({node:myNode, duration:3000}) // fade out for 3 seconds
]).play();
In the previous code, the middle step is a very silly way of achieving nothing. Is there some sort of dojo.fx.sleep
animation that does nothing for a specified length of time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是 dojo 用户,但 JQuery 和 Prototype 的常见习惯用法是延迟属性,它似乎也存在于 Dojo 中:
I'm not a dojo user, but the common idiom from JQuery and Prototype is the delay property, which also seems to be present in Dojo:
肯定的是目前还没有; 实现此效果的唯一方法是将代码分为睡眠前和睡眠后部分,您在这里已经完成了大部分工作。 我唯一建议的是让 Dojo 在 1o,000 毫秒的时间内尽可能少地做事; 正如您现在所看到的,正在调用 fadeIn() 方法,虽然可能可以忽略不计,但它正在运行至少一个条件语句(以检查是否需要修改不透明度)属性),这肯定比让脚本什么也不做要慢一些。
Positive there isn't at this point in time; the only way to achieve the effect is to split your code into pre-sleep and post-sleep sections, which you've pretty much done here. The only thing I'd recommend is having Dojo do as little as possible during the 1o,ooo-millisecond duration; as you have it now, the fadeIn() method is being called and, while probably negligible, the fact that it is running at least one conditional statement (to check whether or not it needs to modify an opacity property), it is definitely a bit slower than just having the script do nothing.