I am creating a diagram application in which I hide and show few elements e.g.
var c = paper.circle(10, 10, 10);
c.hide()
var c2 = paper.circle(10, 10, 10);
c2.show()
Now I want to act upon such shapes e.g. calculate bounding box etc but I am not able to find how to get if shape is hidden or not? Is there something like this shape.is_visible() or shape.attr('visible')
I am creating a diagram application in which I hide and show few elements e.g.
var c = paper.circle(10, 10, 10);
c.hide()
var c2 = paper.circle(10, 10, 10);
c2.show()
Now I want to act upon such shapes e.g. calculate bounding box etc but I am not able to find how to get if shape is hidden or not? Is there something like this shape.is_visible() or shape.attr('visible')
Share Improve this question asked Jul 11, 2010 at 10:55 Anurag UniyalAnurag Uniyal 88.8k41 gold badges180 silver badges221 bronze badges 1- 1 this really ought to be in the raphael api, can't believe we have to implement it ourselves – chrismarx Commented Jun 4, 2013 at 15:42
1 Answer
Reset to default 17I took a look at the documentation and source code and cooked this up (untested):
Raphael.el.is_visible = function() {
return (this.node.style.display !== "none");
}
Call as follows:
var c = paper.circle(10, 10, 10);
c.hide();
if (c.is_visible())
alert("Visible");
else
alert("Invisible");