如何在Raphael js中在屏幕(浏览器)的边缘画一条线



我想用Raphael绘制(动画化一条线)到屏幕/浏览器的边缘,例如从x=100,y=100像素到屏幕的最右侧边缘。

我知道如何做动画部分,我只需要知道如何动态地找到最正确的坐标。

如何在浏览器中不创建水平滚动条的情况下做到这一点?

这在拉斐尔的作品中可能吗?

到目前为止我的代码:

var paper = Raphael(100, 100, ???, 1);
var lineToEdge = paper.path("M0 0");
lineToEdge.attr(fillerLine);
var anim = Raphael.animation({path: "M0 0L??? 100"}, 500);
lineToEdge.animate(anim.delay(2500));

-变量会以某种方式给我最右边的x位置

使用Javascript的window.screen对象来获取这些信息。

请参阅:http://www.javascriptkit.com/howto/newtech3.shtml

所以你的代码看起来像(对不起,我自己还没有测试过):

var paper = Raphael(100, 100, screen.width, 1);
var lineToEdge = paper.path("M0 0");
lineToEdge.attr(fillerLine);
var anim = Raphael.animation({path: "M0 0L"+screen.width+" 100"}, 500);
lineToEdge.animate(anim.delay(2500));

最新更新