Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
97abe4b5
...
97abe4b58af2fafd6ef36a3efa69e48607a9eb3e
authored
2013-11-16 23:45:31 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed elem visibility computation method - refs #715
1 parent
9eb64d1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
modules/clientutils.js
tests/site/visible.html
modules/clientutils.js
View file @
97abe4b
...
...
@@ -130,19 +130,24 @@
/**
* Checks if a given DOM element is visible in remove page.
*
* @param Object element DOM element
* @param
Object element DOM element
* @return Boolean
*/
this
.
elementVisible
=
function
elementVisible
(
elem
)
{
var
style
;
try
{
var
comp
=
window
.
getComputedStyle
(
elem
,
null
);
return
comp
.
visibility
!==
'hidden'
&&
comp
.
display
!==
'none'
&&
elem
.
offsetHeight
>
0
&&
elem
.
offsetWidth
>
0
;
style
=
window
.
getComputedStyle
(
elem
,
null
);
}
catch
(
e
)
{
return
false
;
}
var
hidden
=
style
.
visibility
===
'hidden'
||
style
.
display
===
'none'
;
if
(
hidden
)
{
return
false
;
}
if
(
style
.
display
===
"inline"
)
{
return
true
;
}
return
elem
.
clientHeight
>
0
&&
elem
.
clientWidth
>
0
;
}
/**
...
...
tests/site/visible.html
View file @
97abe4b
...
...
@@ -14,4 +14,4 @@
<img
src=
"images/phantom.png"
id=
"img2"
>
<img
src=
"images/phantom.png"
id=
"img3"
style=
"visibility:hidden"
>
</body>
</html>
\ No newline at end of file
</html>
...
...
Please
register
or
sign in
to post a comment