Reputation: 5004
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();
});
Upvotes: 4
Views: 5108
Reputation: 57685
As Dmitry points out, sets can be pushed into other sets, so your code should work. Try it out with this jsFiddle..
Upvotes: 6