Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Added positioning fix for fixed containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Jan 20, 2011
1 parent e58c51f commit 5a91e6f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 65 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Thu Jan 20 14:04:50 2011 +0000
* Date: Thu Jan 20 15:37:41 2011 +0000
*/

/* Fluid class for determining actual width in IE */
Expand Down
13 changes: 9 additions & 4 deletions dist/jquery.qtip.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Thu Jan 20 14:04:50 2011 +0000
* Date: Thu Jan 20 15:37:41 2011 +0000
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
Expand Down Expand Up @@ -174,16 +174,18 @@ function QTip(target, options, id, attr)

function offset(elem, container) {
var pos = { left: 0, top: 0 },
type,
addScroll = !$.fn.qtip.plugins.iOS,
$container = $(container),
offsetParent, parentIsContainer;

if(container) {
if($container.css('position') !== 'static') {
type = $.css(container, 'position');

if(type !== 'static') {
pos = offset(container);
pos.left *= -1; pos.top *= -1;
}
else if($container.css('overflow') !== 'visible') {
else if($.css(container, 'overflow') !== 'visible') {
pos.left -= container.scrollLeft;
pos.top -= container.scrollTop;
}
Expand All @@ -194,6 +196,9 @@ function QTip(target, options, id, attr)
offsetParent = elem.offsetParent;
parentIsContainer = offsetParent === container;

// Account for fixed containers
if(offsetParent === docBody && type === 'fixed') { addScroll = TRUE; }

pos.left += elem.offsetLeft - (addScroll && offsetParent && !parentIsContainer ? offsetParent.scrollLeft : 0);
pos.top += elem.offsetTop - (addScroll && offsetParent && !parentIsContainer ? offsetParent.scrollTop : 0);
}
Expand Down

0 comments on commit 5a91e6f

Please sign in to comment.