将 Raphael 集合嵌套在 Raphael javascript 库的 Raphael 集合中
我一直在尝试将集合嵌套在集合中,但没有成功。
这个概念来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Dmitry 指出的那样,集合可以被推入其他集合中,因此您的代码应该可以工作。 使用这个 jsFiddle 尝试一下。。
As Dmitry points out, sets can be pushed into other sets, so your code should work. Try it out with this jsFiddle..