Delay between opacity: 0 and starting animation to opacity: 1 in Raphael JS

為{幸葍}努か 提交于 2019-12-13 02:33:35

问题


I am using Raphael JS library and here is my code:

 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);

I have tried rectangle.attr({opacity: 0}).delay(5000); and also this: rectangle.attr({opacity: 0}, 5000); , but none of these seems to work at all.

What is the simplest way to wait some time before excuting other code. I would not like to use nested functions or for loops at all, if possible.


回答1:


Use Raphael.animation and Animation.delay.

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


来源:https://stackoverflow.com/questions/11626589/delay-between-opacity-0-and-starting-animation-to-opacity-1-in-raphael-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!