Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Element.Methods.isVisible = (function() {
- function ancestry(element){
- var ancestors = [element];
- while(ancestors.last() !== document.body)
- ancestors.push(element = element.parentNode);
- return ancestors;
- }
- function getAncestricStyles(element, style){
- return ancestry(element).invoke('getStyle', style);
- }
- function isVisible(element){
- return !(
- getAncestricStyles(element, 'display').include('none') ||
- getAncestricStyles(element, 'opacity').include('0') ||
- getAncestricStyles(element, 'visibility').include('hidden') ||
- getAncestricStyles(element, 'height').include('0') ||
- getAncestricStyles(element, 'width').include('0')
- );
- }
- return isVisible;
- })();
Add Comment
Please, Sign In to add comment