是否有一些 dojo.fx.sleep 函数可以在 dojo.fx.chain 动画中使用?

发布于 2024-07-13 12:51:03 字数 447 浏览 11 评论 0原文

我想在一秒钟内淡入一个节点。 然后保持 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城旧梦 2024-07-20 12:51:03

我不是 dojo 用户,但 JQuery 和 Prototype 的常见习惯用法是延迟属性,它似乎也存在于 Dojo 中:

dojo.addOnLoad(function() { 
  var animationArguments = {
    node: “testHeading”,
    duration: 1000,       // ms to run animation
    delay: 250            // ms to stall before playing
  };

  dojo.fadeOut(animationArguments).play();
});

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.addOnLoad(function() { 
  var animationArguments = {
    node: “testHeading”,
    duration: 1000,       // ms to run animation
    delay: 250            // ms to stall before playing
  };

  dojo.fadeOut(animationArguments).play();
});
紫南 2024-07-20 12:51:03

肯定的是目前还没有; 实现此效果的唯一方法是将代码分为睡眠前和睡眠后部分,您在这里已经完成了大部分工作。 我唯一建议的是让 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文