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

Commit

Permalink
Optimize offset() calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Feb 27, 2012
1 parent 667a7b6 commit 27f6e16
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 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 Feb 21 17:23:25 2012 +0000
* Date: Thu Feb 23 18:28:16 2012 +0000
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -1792,7 +1792,7 @@ PLUGINS = QTIP.plugins = {
// Custom (more correct for qTip!) offset calculator
offset: function(elem, container) {
var pos = elem.offset(),
docBody = document.body,
docBody = elem.closest('body')[0],
parent = container, scrolled,
coffset, overflow;

Expand All @@ -1814,9 +1814,8 @@ PLUGINS = QTIP.plugins = {
// If this is the first parent element with an overflow of "scroll" or "auto", store it
if(!scrolled && (overflow = parent.css('overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = parent; }
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());
while((parent = $(parent[0].offsetParent)).length);

// Compensate for containers scroll if it also has an offsetParent
if(scrolled && scrolled[0] !== docBody) { scroll( scrolled, 1 ); }
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 Feb 21 17:23:25 2012 +0000
* Date: Thu Feb 23 18:28:16 2012 +0000
*/

/* Core qTip styles */
Expand Down
7 changes: 3 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: Tue Feb 21 17:23:25 2012 +0000
* Date: Thu Feb 23 18:28:16 2012 +0000
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -1792,7 +1792,7 @@ PLUGINS = QTIP.plugins = {
// Custom (more correct for qTip!) offset calculator
offset: function(elem, container) {
var pos = elem.offset(),
docBody = document.body,
docBody = elem.closest('body')[0],
parent = container, scrolled,
coffset, overflow;

Expand All @@ -1814,9 +1814,8 @@ PLUGINS = QTIP.plugins = {
// If this is the first parent element with an overflow of "scroll" or "auto", store it
if(!scrolled && (overflow = parent.css('overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = parent; }
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());
while((parent = $(parent[0].offsetParent)).length);

// Compensate for containers scroll if it also has an offsetParent
if(scrolled && scrolled[0] !== docBody) { scroll( scrolled, 1 ); }
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/core.js
Expand Up @@ -1720,7 +1720,7 @@ PLUGINS = QTIP.plugins = {
// Custom (more correct for qTip!) offset calculator
offset: function(elem, container) {
var pos = elem.offset(),
docBody = document.body,
docBody = elem.closest('body')[0],
parent = container, scrolled,
coffset, overflow;

Expand All @@ -1742,9 +1742,8 @@ PLUGINS = QTIP.plugins = {
// If this is the first parent element with an overflow of "scroll" or "auto", store it
if(!scrolled && (overflow = parent.css('overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = parent; }
}
if(parent[0] === docBody) { break; }
}
while(parent = parent.offsetParent());
while((parent = $(parent[0].offsetParent)).length);

// Compensate for containers scroll if it also has an offsetParent
if(scrolled && scrolled[0] !== docBody) { scroll( scrolled, 1 ); }
Expand Down

0 comments on commit 27f6e16

Please sign in to comment.