我正在使用 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.animation和 Animation.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/