Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if raphael object is hidden?

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')

like image 709
Anurag Uniyal Avatar asked Jul 11 '10 10:07

Anurag Uniyal


Video Answer


1 Answers

I 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");
like image 179
TNi Avatar answered Oct 13 '22 19:10

TNi