Skip to content

Instantly share code, notes, and snippets.

@cheeaun
Created March 3, 2009 14:34
Show Gist options
  • Save cheeaun/73342 to your computer and use it in GitHub Desktop.
Save cheeaun/73342 to your computer and use it in GitHub Desktop.
Mootools Element extras: isVisible and isHidden
/*
* Inspired from http://github.com/jeresig/sizzle/commit/7631f9c3f85e5fa72ac51532399cb593c2cdc71f
* and this http://github.com/jeresig/sizzle/commit/5716360040a440041da19823964f96d025ca734b
* and then http://dev.jquery.com/ticket/4512
*/
Element.implement({
isHidden: function(){
var w = this.offsetWidth, h = this.offsetHeight,
force = /^tr$/i.test(this.tagName);
return (w===0 && h===0 && !force) ? true : (w!==0 && h!==0 && !force) ? false : this.getStyle('display') === 'none';
},
isVisible: function(){
return !this.isHidden();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment