javascript - 不透明度之间的延迟 : 0 and starting animation to opacity: 1 in Raphael JS

标签 javascript raphael

我正在使用 Raphael JS 库,这是我的代码:

 var rectangle = paper.rect(0, 0, 5, 5);                        
    rectangle.attr({opacity: 0});
    // I need here a 5 seconds delay, before starting an animation
    rectangle.animate({opacity: 1}, 2000);

我试过 rectangle.attr({opacity: 0}).delay(5000); 还有这个:rectangle.attr({opacity: 0}, 5000); ,但这些似乎都不起作用。

在执行其他代码之前等待一段时间的最简单方法是什么。如果可能的话,我根本不想使用嵌套函数或 for 循环。

最佳答案

使用Raphael.animationAnimation.delay .

var anim = Raphael.animation({opacity: 0, opacity: 1}, 1000);
rectangle.animate(anim.delay(5000 /* the delay (ms) */));

关于javascript - 不透明度之间的延迟 : 0 and starting animation to opacity: 1 in Raphael JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11626589/

相关文章:

javascript - 单击按钮在 Facebook 上发布文本

javascript - 重复 SVG 路径

javascript - pouchDB allDocs 返回未定义

svg - 将 kml 多边形转换为 svg 路径

javascript - 如何在 Javascript 中使用旁边元素的值更改单元格的元素?

javascript - CheckBoxes React Native Map函数返回错误: Too many re-renders. React限制渲染数量以防止无限循环

javascript - 拉斐尔Js : How to animate a path after translate

javascript - 拉斐尔:将模糊的点放在前面

javascript - 从外部方法调用时 RaphaelJS animate 不起作用

javascript - 拉斐尔累积与绝对缩放/旋转/平移?