拉斐尔,不断旋转的路径

发布于 2024-12-02 23:25:58 字数 1131 浏览 1 评论 0原文

我在拉斐尔中有一条路径,我希望它不断旋转某个点,

我写了这样的:

window.onload = function(){

var paper = Raphael(10, 150, 320, 200);
var path = paper.path('M50 40 L50 90');
var circle = paper.circle(50, 40, 10);
circle.attr('fill', 'green');

drawWheel(path, circle);
}

function drawWheel(path, circle){

path.animate({rotation: '360 50 90'}, 10000);
circle.animate({rotation: '360 50 90'}, 10000)
timeout = setTimeout("drawWheel(path, circle);", 10000);

}

因此,当加载页面时,我正在创建拉斐尔路径和圆圈,然后将其传递给方法drawWheel,该方法对这些对象进行动画处理

我想在 10 秒后再次调用它,以便用户会看到不断旋转的对象,

首先一切都很好,直到调用 setTimeout

比我在 firebug 中收到错误“路径未定义”

我在调用setTimeout 错误还是什么?


我修改了脚本并创建了路径全局变量,所以现在脚本(最简单的版本)看起来像这样:

window.onload = function(){

    var paper = Raphael(10, 150, 320, 200);
    path = paper.path('M50 40 L50 90');
    drawWheel(path, circle);
}

function drawWheel(path){

    path.animate({rotation: '360 50 90'}, 10000);
    timeout = setTimeout("drawWheel(path);", 10000);
}

所以现在 firebug 中出现了错误,但是路径正在旋转 360 度并停止。

即使 setTimeout 正在调用,但在一个动画之后什么也没有发生

有什么想法吗?

I have a path in Raphael, and I want it to constantly rotating by some point

I have writen this :

window.onload = function(){

var paper = Raphael(10, 150, 320, 200);
var path = paper.path('M50 40 L50 90');
var circle = paper.circle(50, 40, 10);
circle.attr('fill', 'green');

drawWheel(path, circle);
}

function drawWheel(path, circle){

path.animate({rotation: '360 50 90'}, 10000);
circle.animate({rotation: '360 50 90'}, 10000)
timeout = setTimeout("drawWheel(path, circle);", 10000);

}

So when the page is load I am creating raphael path and circle and than I am passing it to method drawWheel, which is animating those objects

Than I want to call it again after 10 seconds, so that the user would see constantly rotating object,

first all is going good till the calling setTimeout

than I am getting an error in firebug "path is not defined"

Am I calling the setTimeout wrong or what ?


I have modified the script and I made path global variable so now the script (the simplest version) looks like this :

window.onload = function(){

    var paper = Raphael(10, 150, 320, 200);
    path = paper.path('M50 40 L50 90');
    drawWheel(path, circle);
}

function drawWheel(path){

    path.animate({rotation: '360 50 90'}, 10000);
    timeout = setTimeout("drawWheel(path);", 10000);
}

So now there is now error in firebug at all, but the path is rotating 360 degrees and stops.

Even the setTimeout is calling, but after one animation nothing more is happening

Any ideas pleas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文