diff --git a/jquery.overflowing.js b/jquery.overflowing.js index f3a8cd2..e95cd68 100644 --- a/jquery.overflowing.js +++ b/jquery.overflowing.js @@ -13,6 +13,7 @@ this.options = options || window this.each(function(){ + if ($.isWindow(this)) return false var $this = $(this) elPosition = $this.position() elWidth = $this.width() @@ -22,15 +23,21 @@ parents.push($parentsTo) for(var i=0; i(parentHeight+parentPosition.top) - || elPosition.left>(parentWidth+parentPosition.left) - || (elPosition.top + elHeight) > (parentHeight+parentPosition.top) - || (elPosition.left+elWidth) > (parentWidth+parentPosition.left)){ + var $parent = $(parents[i]) + if ($.isWindow($parent[0])) break + var absPosition = !!~['absolute', 'fixed'].indexOf($parent.css('position')) + var parentPosition = $parent.position() + var parentWidth = $parent.width() + var parentHeight = $parent.height() + var parentToBottom = absPosition ? parentHeight : (parentHeight+parentPosition.top) + var parentToRight = absPosition ? parentWidth : (parentWidth+parentPosition.left) + + if ( elPosition.top < 0 + || elPosition.left < 0 + || elPosition.top > parentToBottom + || elPosition.left > parentToRight + || (elPosition.top + elHeight) > parentToBottom + || (elPosition.left + elWidth) > parentToRight) { status = true $(parents[i]).addClass('overflowed') overflowed.push(parents[i])