0

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

1 Answer 1

0

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));
1
  • Note that if you want to use a callback, you should wrap it in something like underscore's _.once, as otherwise it is fired for each of the elements in all, which in this example is 7 times.
    – AJP
    Nov 9, 2013 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.