From ac1a3c8604cde0821660f4b4e9bc1a958f35f70e Mon Sep 17 00:00:00 2001 From: Sujay Krishna Suresh Date: Mon, 8 Apr 2013 18:55:00 +0530 Subject: [PATCH] Checking the size of the element Adding a check on the client size of the element where size = (offsetWidth * offsetHeight). This will be able to detect those elements that are hidden or zero-sized in the layout. --- jquery.visible.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.visible.js b/jquery.visible.js index 764464e..85986ab 100644 --- a/jquery.visible.js +++ b/jquery.visible.js @@ -19,9 +19,10 @@ _top = $t.offset().top, _bottom = _top + $t.height(), compareTop = partial === true ? _bottom : _top, - compareBottom = partial === true ? _top : _bottom; + compareBottom = partial === true ? _top : _bottom, + clientSize = this.offsetWidth * this.offsetHeight; - return ((compareBottom <= viewBottom) && (compareTop >= viewTop)); + return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop)); }; -})(jQuery); \ No newline at end of file +})(jQuery);