fixed elem visibility computation method - refs #715
Showing
2 changed files
with
12 additions
and
7 deletions
... | @@ -130,19 +130,24 @@ | ... | @@ -130,19 +130,24 @@ |
130 | /** | 130 | /** |
131 | * Checks if a given DOM element is visible in remove page. | 131 | * Checks if a given DOM element is visible in remove page. |
132 | * | 132 | * |
133 | * @param Object element DOM element | 133 | * @param Object element DOM element |
134 | * @return Boolean | 134 | * @return Boolean |
135 | */ | 135 | */ |
136 | this.elementVisible = function elementVisible(elem) { | 136 | this.elementVisible = function elementVisible(elem) { |
137 | var style; | ||
137 | try { | 138 | try { |
138 | var comp = window.getComputedStyle(elem, null); | 139 | style = window.getComputedStyle(elem, null); |
139 | return comp.visibility !== 'hidden' && | ||
140 | comp.display !== 'none' && | ||
141 | elem.offsetHeight > 0 && | ||
142 | elem.offsetWidth > 0; | ||
143 | } catch (e) { | 140 | } catch (e) { |
144 | return false; | 141 | return false; |
145 | } | 142 | } |
143 | var hidden = style.visibility === 'hidden' || style.display === 'none'; | ||
144 | if (hidden) { | ||
145 | return false; | ||
146 | } | ||
147 | if (style.display === "inline") { | ||
148 | return true; | ||
149 | } | ||
150 | return elem.clientHeight > 0 && elem.clientWidth > 0; | ||
146 | } | 151 | } |
147 | 152 | ||
148 | /** | 153 | /** | ... | ... |
... | @@ -14,4 +14,4 @@ | ... | @@ -14,4 +14,4 @@ |
14 | <img src="images/phantom.png" id="img2"> | 14 | <img src="images/phantom.png" id="img2"> |
15 | <img src="images/phantom.png" id="img3" style="visibility:hidden"> | 15 | <img src="images/phantom.png" id="img3" style="visibility:hidden"> |
16 | </body> | 16 | </body> |
17 | </html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
17 | </html> | ... | ... |
-
Please register or sign in to post a comment