开发者

RaphaelJS - Finding a point in a path while animating

开发者 https://www.devze.com 2023-01-30 17:16 出处:网络
Let\'s say I have an ellipse e that I wanted to animate along path p. If I began to animate the ellipse, but then d开发者_C百科ecided to stop the animation, is there any way I could restart the anima

Let's say I have an ellipse e that I wanted to animate along path p.

If I began to animate the ellipse, but then d开发者_C百科ecided to stop the animation, is there any way I could restart the animation from it's current point? I haven't been able to find a way to determine the ellipse's current point along a path after stopping the animation.

Here is my animation code (all standard):

e.attr({ rx: 15, ry: 5 }).animateAlong(p, 15000, true, function () {
                    e.attr({ rx: 10, ry: 10 });
                    clicked = false;
                });


How about you define the last points outside using onAnimate?

var lastX = 15, lastY = 5;
e.onAnimation(function() {
    lastX = e.attr('rx');
    lastY = e.attr('ry');
});

e.attr({ rx: lastX, ry: lastY }).animateAlong(p, 15000, true, function () {
    e.attr({ rx: 10, ry: 10 });
    clicked = false;
});

So if you run this code several times, inside a function or whatever, you ellipse will start not at 15, 5 but at the last point in the animation (before it was interrupted).

This what you meant?

0

精彩评论

暂无评论...
验证码 换一张
取 消