将 Raphael 集合嵌套在 Raphael javascript 库的 Raphael 集合中

发布于 2024-09-30 22:08:03 字数 738 浏览 0 评论 0原文

我一直在尝试将集合嵌套在集合中,但没有成功。

这个概念来自 Photoshop,您可以将元素分组到一个文件夹/集合中,并将它们嵌套到另一个文件夹/集合中。

我试图轻松地将两个或多个集合合并为一组,因此我不必手动将所有内容拆开以再次集成代码。

此步骤是为集合的集体行为控制让路,例如鼠标悬停、单击、平移和转换。

有没有人经历过这个并找到解决这个问题的方法? 感谢任何解决此问题的帮助。

为了详细说明,这里有一些我想要做的人为的示例代码:

var r = Raphael("holder");
r.height = 400
r.width = 300

var buttons = r.set();
var target_objects = r.set();

buttons.push(
    r.rect(0,0,r.width/10,r.height/10).attr({fill:"#000"})
);

target_objects.push(
    r.rect(50,50,r.width/5,r.height/5).attr({fill:"#0F0"})
);

var super_set = r.set();

# Trying to combine sets. Note: this of course doesn't work
super_set.push(buttons,target_objects);

super_set.mouseover(function(){
    alert();
});

I've been trying to nest sets within sets but to no avail.

This concept comes from, photoshop, where you can group elements into a folder/set, and nest them into another folder/set.

I'm trying to combine two or more sets into one easily, so I don't have to manually take everything apart to integrate the code again.

This step is to make way for collective behavior control of the set, e.g. mouse hovers, clicks, translations, and transformations.

Has anyone experience this and found a workaround of sorts to this problem please?
Any help to tackle this issue is appreciated.

To elaborate, here's some contrived example code of what I'm trying to do:

var r = Raphael("holder");
r.height = 400
r.width = 300

var buttons = r.set();
var target_objects = r.set();

buttons.push(
    r.rect(0,0,r.width/10,r.height/10).attr({fill:"#000"})
);

target_objects.push(
    r.rect(50,50,r.width/5,r.height/5).attr({fill:"#0F0"})
);

var super_set = r.set();

# Trying to combine sets. Note: this of course doesn't work
super_set.push(buttons,target_objects);

super_set.mouseover(function(){
    alert();
});

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生死何惧 2024-10-07 22:08:03

正如 Dmitry 指出的那样,集合可以被推入其他集合中,因此您的代码应该可以工作。 使用这个 jsFiddle 尝试一下。

As Dmitry points out, sets can be pushed into other sets, so your code should work. Try it out with this jsFiddle..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文