Guest User

Untitled

a guest
Apr 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Element.Methods.isVisible = (function() {
  2.  
  3. function ancestry(element){
  4. var ancestors = [element];
  5. while(ancestors.last() !== document.body)
  6. ancestors.push(element = element.parentNode);
  7. return ancestors;
  8. }
  9.  
  10. function getAncestricStyles(element, style){
  11. return ancestry(element).invoke('getStyle', style);
  12. }
  13.  
  14. function isVisible(element){
  15. return !(
  16. getAncestricStyles(element, 'display').include('none') ||
  17. getAncestricStyles(element, 'opacity').include('0') ||
  18. getAncestricStyles(element, 'visibility').include('hidden') ||
  19. getAncestricStyles(element, 'height').include('0') ||
  20. getAncestricStyles(element, 'width').include('0')
  21. );
  22. }
  23.  
  24. return isVisible;
  25. })();
Add Comment
Please, Sign In to add comment