animateAlong in 2.0?

2,100 views
Skip to first unread message

Carlos Bueno

unread,
Oct 30, 2011, 5:11:39 PM10/30/11
to Raphaël
2.0 looks great, but the Element.animateAlong method is missing. Is
this by design? I tried hacking in the implementation from 1.3.2 but
with no success:


function along(isBack) {
return function (path, ms, rotate, callback) {
var params = {back: isBack};
Raphael.is(rotate, "function") ? (callback = rotate) :
(params.rot = rotate);
path && (path = path.attrs.path);
path && (params.along = path);
return this.animate(params, ms, callback);
};
}

Raphael.el.animateAlong = along();
Raphael.el.animateAlongBack = along(1);

Claudio Squarcella

unread,
Nov 28, 2011, 6:50:30 AM11/28/11
to raph...@googlegroups.com
UP.

is there a reason (e.g. incompatibility with the new implementation for animations) ?

Thanks,
Claudio

charles thomas

unread,
Nov 28, 2011, 8:33:04 AM11/28/11
to raph...@googlegroups.com
Yes, it disappeared in 2 hasn't it.

What you could do is look at this example as a work around maybe.
It's quite small once you get rid of the extra bits for the demo.


It's implemented by a drag and drop call as follows..
sliderButton.drag(move, start, up);

but the algorithm could quite easily (but with some thought) be changed into an animation
that travels along the path.



From: Claudio Squarcella <claudio.s...@gmail.com>
To: raph...@googlegroups.com
Sent: Monday, November 28, 2011 6:50:30 AM
Subject: Re: animateAlong in 2.0?

--
You received this message because you are subscribed to the Google Groups "Raphaël" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/raphaeljs/-/aNdwHxo8sQ8J.
To post to this group, send an email to raph...@googlegroups.com.
To unsubscribe from this group, send email to raphaeljs+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/raphaeljs?hl=en-GB.


Lukas Diener

unread,
Nov 28, 2011, 12:27:33 PM11/28/11
to raph...@googlegroups.com
You can use getTotalLength() and getPointAtLength() of the path as in my example: http://jsfiddle.net/gyeSf/17/

Dmitry Baranovskiy

unread,
Nov 28, 2011, 7:08:48 PM11/28/11
to raph...@googlegroups.com

Claudio Squarcella

unread,
Nov 29, 2011, 4:15:56 AM11/29/11
to Raphaël
Hi guys,

thanks for all your answers.

Dmitry: so I assume there's a reason why it is not anymore a standard
feature. Any plans for the future?

Thanks
Claudio

On Nov 29, 1:08 am, Dmitry Baranovskiy <dmitry.baranovs...@gmail.com>
wrote:
> http://raphaeljs.com/gear.html

BL

unread,
Nov 8, 2012, 12:44:08 PM11/8/12
to raph...@googlegroups.com
I hate to revive a year-old thread but I'm wondering the answer to Claudio's last question. I would like to be able to animate sets along paths, and I'm pretty sure I'm not the only one.

Bill Baritompa

unread,
Sep 16, 2013, 1:17:07 AM9/16/13
to raph...@googlegroups.com
Hi Dmitry, You've done a great job. I'm total new to Javascript.  I think there is a bug in Raphael.findDotsAtSegment which causes a problem with animating along a path.  Attached is a slight mod of gear.html where I try to move an arrow in the direction of a path. As you can see the arrow is always tangent to the path, but flips at times to point in the direction of travel or away from the direction of travel. The problem is that in findDotsAtSegment angle of the tangent line gets adjusted by 180 at times. I think having angle being the angle of the tangent vector will solve this problem. I think this code will fix it, but I'm not sure  if it might cause other problems.


            // mod to get angle of tangent vector 0 is motion to East, 90 to S
            alpha = (-90 - math.atan2(mx - nx, my - ny) * 180 / PI);
            (alpha >= -180) || (alpha += 360);
 // original code gives angle of tangent line, but flips tangent vector
 //         alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
//          (mx > nx || my < ny) && (alpha += 180);


 
gearmod.html
Reply all
Reply to author
Forward
0 new messages