我有一系列raphael动画,我想按特定顺序触发。为什么我的setTimeouts函数不工作?
- 淡入曲线。
- 淡入球。
- 沿曲线动画化球。
我在每个函数之间都有一个setTimeout,但动画只是同时触发。
View it on JSFiddle或在这里:
Raphael("bounce", 640, 480, function() {
var r = this,
p = r.path("M0,77.255c0,0,269.393,37.431,412.96,247.653 c0,0,95.883-149.719,226.632-153.309").attr({stroke: "#666", opacity: .0, "stroke-width": 1}),
len = p.getTotalLength(),
e = r.circle(0, 0, 7).attr({stroke: "none", fill: "#000", opacity:0}).onAnimation(function() {
var t = this.attr("transform");
});
r.customAttributes.along = function (v) {
var point = p.getPointAtLength(v * len);
return {
transform: "t" + [point.x, point.y] + "r" + point.alpha
};
};
e.attr({along: 0});
var rotateAlongThePath = true;
function fadecurve(ca,ba,aa,ab){
ca.animate({opacity:1},2000);
setTimeout(fadeball(ba,aa,ab),6000);
}
function fadeball(ba,aa,ab) {
ba.animate({opacity:1},400);
setTimeout(run(ba, aa,ab),5000);
}
function run(ba,aa,ab) {
ba.animate({opacity:1},400);
ba.animate({along: aa}, ab, ">", function() {
ba.attr({along: aa});
});
}
fadecurve(p,e,.9,500);
});
谢谢!就是我想要的! – 2012-04-26 16:55:02
@andrewnguyen:欢迎您:) – Sarfraz 2012-04-26 16:56:20