不透明度:0 和开始动画到不透明度之间的延迟:Raphael JS 中的 1 [英] Delay between opacity: 0 and starting animation to opacity: 1 in Raphael JS

查看:31
本文介绍了不透明度:0 和开始动画到不透明度之间的延迟:Raphael JS 中的 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

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

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.

推荐答案

使用 Raphael.animationAnimation.delay.

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

这篇关于不透明度:0 和开始动画到不透明度之间的延迟:Raphael JS 中的 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆