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

Commit

Permalink
offset function now correctly takes into account non-static body
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed May 31, 2011
1 parent ec19a26 commit 7afc126
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
13 changes: 8 additions & 5 deletions dist/jquery.qtip.basic.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue May 31 11:49:21 2011 +0100
* Date: Tue May 31 17:48:21 2011 +0100
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -1658,14 +1658,17 @@ PLUGINS = QTIP.plugins = {
if(parent) {
// Compensate for non-static containers offset
do {
if(parent[0] === docBody) { break; }
else if(parent.css('position') !== 'static') {
coffset = parent.position();
if(parent.css('position') !== 'static') {
coffset = parent[0] === docBody ?
{ left: parseInt(parent.css('left'), 10) || 0, top: parseInt(parent.css('top'), 10) || 0 } :
parent.position();

pos.left -= coffset.left + (parseInt(parent.css('borderLeftWidth'), 10) || 0);
pos.top -= coffset.top + (parseInt(parent.css('borderTopWidth'), 10) || 0);

deep++;
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());

Expand Down
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: Tue May 31 11:49:21 2011 +0100
* Date: Tue May 31 17:48:21 2011 +0100
*/

/* Core qTip styles */
Expand Down
13 changes: 8 additions & 5 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: Tue May 31 11:49:21 2011 +0100
* Date: Tue May 31 17:48:21 2011 +0100
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -1658,14 +1658,17 @@ PLUGINS = QTIP.plugins = {
if(parent) {
// Compensate for non-static containers offset
do {
if(parent[0] === docBody) { break; }
else if(parent.css('position') !== 'static') {
coffset = parent.position();
if(parent.css('position') !== 'static') {
coffset = parent[0] === docBody ?
{ left: parseInt(parent.css('left'), 10) || 0, top: parseInt(parent.css('top'), 10) || 0 } :
parent.position();

pos.left -= coffset.left + (parseInt(parent.css('borderLeftWidth'), 10) || 0);
pos.top -= coffset.top + (parseInt(parent.css('borderTopWidth'), 10) || 0);

deep++;
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());

Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/jquery.qtip.pack.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/core.js
Expand Up @@ -1617,14 +1617,17 @@ PLUGINS = QTIP.plugins = {
if(parent) {
// Compensate for non-static containers offset
do {
if(parent[0] === docBody) { break; }
else if(parent.css('position') !== 'static') {
coffset = parent.position();
if(parent.css('position') !== 'static') {
coffset = parent[0] === docBody ?
{ left: parseInt(parent.css('left'), 10) || 0, top: parseInt(parent.css('top'), 10) || 0 } :
parent.position();

pos.left -= coffset.left + (parseInt(parent.css('borderLeftWidth'), 10) || 0);
pos.top -= coffset.top + (parseInt(parent.css('borderTopWidth'), 10) || 0);

deep++;
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());

Expand Down

0 comments on commit 7afc126

Please sign in to comment.