Question

This answer has been accepted but it does not work as glowSet.animate({cx: 100}) will not move the glow as well as the circle. Additionally to animate the glowSet path objects, you need to apply a transformation, something like this but a simple move transformation shrinks the glow paths to 0.

Current approach as a js fiddle, or is there a smarter way of achieving the same thing?:

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));
Was it helpful?

Solution

For the animation you just need to use the translate rather than matrix, for the transform:

// Animation
delay = 300
speed = 1000

_transformedPath = Raphael.transformPath('t100 100');
animGlow = Raphael.animation({transform: _transformedPath}, speed, '<>');
all.animate(animGlow.delay(delay));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top