这个answer has been accepted但它不起作用,因为glowSet.animate({cx:100})不会移动光晕和圆圈。除了为glowSet路径对象设置动画外,还需要应用a transformation, something like this,但是简单的移动变换会将辉光路径缩小为0。
作为js fiddle的当前方法,还是有更聪明的方法来实现同样的目标?:
paper = Raphael(0, 0, 200, 200);
circle = paper.circle(10, 10, 10);
glow = circle.glow();
glow.push(circle);
all = glow;
all.attr("stroke", "#f00");
// Animation
delay = 300
speed = 1000
// Will only animate the glow paths and not the circle
// Also shrinks the glow paths to nothing.
_transformedPath = Raphael.transformPath('M100 100');
animGlow = Raphael.animation({path: _transformedPath}, speed);
all.animate(animGlow.delay(delay + 200));
//We shouldn't want or need to do this. You can apply an
//element.matrix.translate(x, y), followed by a //element.transform(element.matrix.toTransformString()) for
//each of the elements in the glowSet
anim = Raphael.animation({cx: 100, cy: 100}, speed);
circle.animate(anim.delay(delay));
答案 0 :(得分:0)
对于动画,您只需使用translate
而不是matrix
,transform:
// Animation
delay = 300
speed = 1000
_transformedPath = Raphael.transformPath('t100 100');
animGlow = Raphael.animation({transform: _transformedPath}, speed, '<>');
all.animate(animGlow.delay(delay));