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

Commit

Permalink
Added check to make sure tip doesn't extend off the end of the tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Apr 13, 2011
1 parent 623c9b3 commit 94801a0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 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: Wed Apr 13 23:41:51 2011 +0100
* Date: Wed Apr 13 23:43:02 2011 +0100
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
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: Wed Apr 13 23:41:51 2011 +0100
* Date: Wed Apr 13 23:43:02 2011 +0100
*/

/* Fluid class for determining actual width in IE */
Expand Down
12 changes: 7 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: Wed Apr 13 23:41:51 2011 +0100
* Date: Wed Apr 13 23:43:02 2011 +0100
*/

"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 @@ -2337,7 +2337,7 @@ function Tip(qTip, command)

// Calculate tip position
$.each(corners, function(i, side) {
var b, br;
var d, b, br;

if(side === 'center') {
b = precedance === 'y' ? 'left' : 'top';
Expand All @@ -2347,10 +2347,12 @@ function Tip(qTip, command)
else {
b = borderWidth(corner, side, TRUE);
br = borderRadius(corner);
d = i && precedance === 'y' ? 'height' : 'width';

position[ side ] = i ?
borderWidth(corner, side) + (!i ? br : 0) :
offsets[i] + (br > b ? br : 0);
position[ side ] = Math.min(
tooltip[d]() - size[d] - border,
i ? borderWidth(corner, side) + (!i ? br : 0) : offsets[i] + (br > b ? br : 0)
);
}
});

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.

10 changes: 6 additions & 4 deletions src/tips.js
Expand Up @@ -459,7 +459,7 @@ function Tip(qTip, command)

// Calculate tip position
$.each(corners, function(i, side) {
var b, br;
var d, b, br;

if(side === 'center') {
b = precedance === 'y' ? 'left' : 'top';
Expand All @@ -469,10 +469,12 @@ function Tip(qTip, command)
else {
b = borderWidth(corner, side, TRUE);
br = borderRadius(corner);
d = i && precedance === 'y' ? 'height' : 'width';

position[ side ] = i ?
borderWidth(corner, side) + (!i ? br : 0) :
offsets[i] + (br > b ? br : 0);
position[ side ] = Math.min(
tooltip[d]() - size[d] - border,
i ? borderWidth(corner, side) + (!i ? br : 0) : offsets[i] + (br > b ? br : 0)
);
}
});

Expand Down

0 comments on commit 94801a0

Please sign in to comment.