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

Commit

Permalink
Few more reposition updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Apr 26, 2011
1 parent 27379ac commit 8e40228
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 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: Tue Apr 26 13:49:46 2011 +0100
* Date: Tue Apr 26 14:21:13 2011 +0100
*/

/* Fluid class for determining actual width in IE */
Expand Down
22 changes: 12 additions & 10 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 Apr 26 13:49:46 2011 +0100
* Date: Tue Apr 26 14:21:13 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 @@ -1076,20 +1076,21 @@ function QTip(target, options, id, attr)

// Reposition methods
left: function(posLeft) {
var viewportScroll = viewport.offset.left + viewport.scrollLeft,
var isShift = readjust.horizontal === 'shift',
viewportScroll = viewport.offset.left + viewport.scrollLeft,
myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2,
atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2,
tipWidth = readjust.tip.width + readjust.tip.border * 2,
tipAdjust = tip && tip.precedance === 'x' ? tipWidth : 0,
tipAdjust = tip && tip.precedance === 'x' && !isShift ? tipWidth : 0,
overflowLeft = viewportScroll - posLeft - tipAdjust,
overflowRight = posLeft + elemWidth - viewport.width - viewportScroll + tipAdjust,
offset = myWidth - (my.precedance === 'x' || my.x === my.y ? atWidth : 0),
isCenter = my.x === 'center';

// Optional 'shift' style repositioning
if(readjust.horizontal === 'shift') {
if(isShift) {
tipAdjust = tip && tip.precedance === 'y' ? tipWidth : 0;
offset = (my.x === 'left' ? myWidth : -myWidth) - tipAdjust;
offset = (my.x === 'left' ? 1 : -1) * myWidth - tipAdjust;

// Adjust position but keep it within viewport dimensions
position.left += overflowLeft > 0 ? overflowLeft : overflowRight > 0 ? -overflowRight : 0;
Expand Down Expand Up @@ -1117,20 +1118,21 @@ function QTip(target, options, id, attr)
return position.left - posLeft;
},
top: function(posTop) {
var viewportScroll = viewport.offset.top + viewport.scrollTop,
var isShift = readjust.vertical === 'shift',
viewportScroll = viewport.offset.top + viewport.scrollTop,
myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2,
atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2,
tipHeight = readjust.tip.height + readjust.tip.border * 2,
tipAdjust = tip && tip.precedance === 'y' ? tipHeight : 0,
tipAdjust = tip && tip.precedance === 'y' && !isShift ? tipHeight : 0,
overflowTop = viewportScroll - posTop - tipAdjust,
overflowBottom = posTop + elemHeight - viewport.height - viewportScroll + tipAdjust,
offset = myHeight - (my.precedance === 'y' || my.x === my.y ? atHeight : 0),
isCenter = my.y === 'center';

// Optional 'shift' style repositioning
if(readjust.vertical === 'shift') {
if(isShift) {
tipAdjust = tip && tip.precedance === 'x' ? tipHeight : 0;
offset = (my.y === 'top' ? myHeight : -myHeight) - tipAdjust;
offset = (my.y === 'top' ? 1 : -1) * myHeight - tipAdjust;

// Adjust position but keep it within viewport dimensions
position.top += overflowTop > 0 ? overflowTop : overflowBottom > 0 ? -overflowBottom : 0;
Expand Down Expand Up @@ -1243,7 +1245,7 @@ function QTip(target, options, id, attr)
width: viewport[ (viewport[0] === window ? 'w' : 'outerW') + 'idth' ](),
scrollLeft: viewport.scrollLeft(),
scrollTop: viewport.scrollTop(),
offset: viewport.offset() || { left:0, top: 0 }
offset: viewport.offset() || { left: 0, top: 0 }
};

// Adjust position based onviewport and adjustment options
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.

20 changes: 11 additions & 9 deletions src/core.js
Expand Up @@ -1033,20 +1033,21 @@ function QTip(target, options, id, attr)

// Reposition methods
left: function(posLeft) {
var viewportScroll = viewport.offset.left + viewport.scrollLeft,
var isShift = readjust.horizontal === 'shift',
viewportScroll = viewport.offset.left + viewport.scrollLeft,
myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2,
atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2,
tipWidth = readjust.tip.width + readjust.tip.border * 2,
tipAdjust = tip && tip.precedance === 'x' ? tipWidth : 0,
tipAdjust = tip && tip.precedance === 'x' && !isShift ? tipWidth : 0,
overflowLeft = viewportScroll - posLeft - tipAdjust,
overflowRight = posLeft + elemWidth - viewport.width - viewportScroll + tipAdjust,
offset = myWidth - (my.precedance === 'x' || my.x === my.y ? atWidth : 0),
isCenter = my.x === 'center';

// Optional 'shift' style repositioning
if(readjust.horizontal === 'shift') {
if(isShift) {
tipAdjust = tip && tip.precedance === 'y' ? tipWidth : 0;
offset = (my.x === 'left' ? myWidth : -myWidth) - tipAdjust;
offset = (my.x === 'left' ? 1 : -1) * myWidth - tipAdjust;

// Adjust position but keep it within viewport dimensions
position.left += overflowLeft > 0 ? overflowLeft : overflowRight > 0 ? -overflowRight : 0;
Expand Down Expand Up @@ -1074,20 +1075,21 @@ function QTip(target, options, id, attr)
return position.left - posLeft;
},
top: function(posTop) {
var viewportScroll = viewport.offset.top + viewport.scrollTop,
var isShift = readjust.vertical === 'shift',
viewportScroll = viewport.offset.top + viewport.scrollTop,
myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2,
atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2,
tipHeight = readjust.tip.height + readjust.tip.border * 2,
tipAdjust = tip && tip.precedance === 'y' ? tipHeight : 0,
tipAdjust = tip && tip.precedance === 'y' && !isShift ? tipHeight : 0,
overflowTop = viewportScroll - posTop - tipAdjust,
overflowBottom = posTop + elemHeight - viewport.height - viewportScroll + tipAdjust,
offset = myHeight - (my.precedance === 'y' || my.x === my.y ? atHeight : 0),
isCenter = my.y === 'center';

// Optional 'shift' style repositioning
if(readjust.vertical === 'shift') {
if(isShift) {
tipAdjust = tip && tip.precedance === 'x' ? tipHeight : 0;
offset = (my.y === 'top' ? myHeight : -myHeight) - tipAdjust;
offset = (my.y === 'top' ? 1 : -1) * myHeight - tipAdjust;

// Adjust position but keep it within viewport dimensions
position.top += overflowTop > 0 ? overflowTop : overflowBottom > 0 ? -overflowBottom : 0;
Expand Down Expand Up @@ -1200,7 +1202,7 @@ function QTip(target, options, id, attr)
width: viewport[ (viewport[0] === window ? 'w' : 'outerW') + 'idth' ](),
scrollLeft: viewport.scrollLeft(),
scrollTop: viewport.scrollTop(),
offset: viewport.offset() || { left:0, top: 0 }
offset: viewport.offset() || { left: 0, top: 0 }
};

// Adjust position based onviewport and adjustment options
Expand Down

0 comments on commit 8e40228

Please sign in to comment.