diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-13 14:46:43 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-13 14:46:43 +0200 |
commit | c0a5e52f875d3c4179f485e7209bd9e26d691110 (patch) | |
tree | 78fb4b8cf99a3cda96627e549c2e2d9b17815cd8 /ui/jquery.ui.position.js | |
parent | 59b93a7dacc7a02267ffdda4cd5ac603c361d197 (diff) | |
download | jquery-ui-c0a5e52f875d3c4179f485e7209bd9e26d691110.tar.gz jquery-ui-c0a5e52f875d3c4179f485e7209bd9e26d691110.zip |
Position: Finish refactoring of within data
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r-- | ui/jquery.ui.position.js | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index a2aa59d4f..e83c23e44 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -72,11 +72,12 @@ $.fn.position = function( options ) { var target = $( options.of ), withinElement = $( options.within || window ), isWindow = $.isWindow( withinElement[0] ), - withinOffset = withinElement.offset(), within = { element: withinElement, - left: isWindow ? withinElement.scrollLeft() : withinOffset.left, - top: isWindow ? withinElement.scrollTop() : withinOffset.top, + isWindow: isWindow, + offset: withinElement.offset(), + scrollLeft: withinElement.scrollLeft(), + scrollTop: withinElement.scrollTop(), width: isWindow ? withinElement.width() : withinElement.outerWidth(), height: isWindow ? withinElement.height() : withinElement.outerHeight() }, @@ -262,8 +263,9 @@ $.fn.position = function( options ) { $.ui.position = { fit: { left: function( position, data ) { - var withinOffset = data.within.left, - outerWidth = data.within.width, + var within = data.within, + withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, + outerWidth = within.width, collisionPosLeft = position.left - data.collisionPosition.marginLeft, overLeft = withinOffset - collisionPosLeft, overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, @@ -299,7 +301,8 @@ $.ui.position = { } }, top: function( position, data ) { - var withinOffset = data.within.top, + var within = data.within, + withinOffset = within.isWindow ? within.scrollTop : within.offset.top, outerHeight = data.within.height, collisionPosTop = position.top - data.collisionPosition.marginTop, overTop = withinOffset - collisionPosTop, @@ -342,12 +345,10 @@ $.ui.position = { return; } - // TODO refactor the offset/scrollLeft calls - var within = data.within.element, - isWindow = $.isWindow( within[0] ), - withinOffset = ( isWindow ? 0 : within.offset().left ) + within.scrollLeft(), - outerWidth = data.within.width, - offsetLeft = isWindow ? 0 : within.offset().left, + var within = data.within, + withinOffset = ( within.isWindow ? 0 : within.offset.left ) + within.scrollLeft, + outerWidth = within.width, + offsetLeft = within.isWindow ? 0 : within.offset.left, collisionPosLeft = position.left - data.collisionPosition.marginLeft, overLeft = collisionPosLeft - offsetLeft, overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, @@ -382,12 +383,10 @@ $.ui.position = { return; } - // TODO refactor the offset/scrollLeft calls - var within = data.within.element, - isWindow = $.isWindow( within[0] ), - withinOffset = ( isWindow ? 0 : within.offset().top ) + within.scrollTop(), - outerHeight = data.within.height, - offsetTop = isWindow ? 0 : within.offset().top, + var within = data.within, + withinOffset = ( within.isWindow ? 0 : within.offset.top ) + within.scrollTop, + outerHeight = within.height, + offsetTop = within.isWindow ? 0 : within.offset.top, collisionPosTop = position.top - data.collisionPosition.marginTop, overTop = collisionPosTop - offsetTop, overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, |