How to know if raphael object is hidden?

被刻印的时光 ゝ 提交于 2019-12-21 03:36:10

问题


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


回答1:


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");


来源:https://stackoverflow.com/questions/3222778/how-to-know-if-raphael-object-is-hidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!