Skip to content

Commit b73dbf0

Browse files
Merge pull request #10 from mschlitz-trux/tooltip-ignore-margins
Tooltip ignore margins
2 parents 3602292 + e211547 commit b73dbf0

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

dist/ui-bootstrap-tpls.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,21 +2589,21 @@ angular.module('ui.bootstrap.position', [])
25892589
var targetWidth = angular.isDefined(targetElem.offsetWidth) ? targetElem.offsetWidth : targetElem.prop('offsetWidth');
25902590
var targetHeight = angular.isDefined(targetElem.offsetHeight) ? targetElem.offsetHeight : targetElem.prop('offsetHeight');
25912591

2592-
if (includeMargins) {
2593-
var styles = window.getComputedStyle(targetElem);
2594-
var verticalMargin = this.parseStyle(styles.marginTop) + this.parseStyle(styles.marginBottom);
2595-
var horisontalMargin = this.parseStyle(styles.marginLeft) + this.parseStyle(styles.marginRight);
2592+
// if (includeMargins) {
2593+
// var styles = window.getComputedStyle(targetElem);
2594+
// var verticalMargin = this.parseStyle(styles.marginTop) + this.parseStyle(styles.marginBottom);
2595+
// var horisontalMargin = this.parseStyle(styles.marginLeft) + this.parseStyle(styles.marginRight);
25962596

2597-
targetHeight += verticalMargin;
2598-
targetWidth += horisontalMargin;
2599-
}
2597+
// targetHeight += verticalMargin;
2598+
// targetWidth += horisontalMargin;
2599+
// }
26002600

26012601
placement = this.parsePlacement(placement);
26022602

26032603
var hostElemPos = appendTo
26042604
? appendToBody
2605-
? this.offset(hostElem, includeMargins, null)
2606-
: this.offset(hostElem, includeMargins, appendTo)
2605+
? this.offset(hostElem, false, null)
2606+
: this.offset(hostElem, false, appendTo)
26072607
: this.position(hostElem, false);
26082608
var targetElemPos = {top: 0, left: 0, placement: ''};
26092609

@@ -2687,6 +2687,14 @@ angular.module('ui.bootstrap.position', [])
26872687

26882688
targetElemPos.top = Math.round(targetElemPos.top);
26892689
targetElemPos.left = Math.round(targetElemPos.left);
2690+
/* remove half pixel for centering on even-pixel element width/height */
2691+
if (hostElemPos.height % 2 === 0) {
2692+
targetElemPos.top -= 0.5;
2693+
}
2694+
if (hostElemPos.width % 2 === 0) {
2695+
targetElemPos.left -= 0.5;
2696+
}
2697+
26902698
targetElemPos.placement = placement[1] === 'center' ? placement[0] : placement[0] + '-' + placement[1];
26912699

26922700
return targetElemPos;

src/position/position.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,21 +475,21 @@ angular.module('ui.bootstrap.position', [])
475475
var targetWidth = angular.isDefined(targetElem.offsetWidth) ? targetElem.offsetWidth : targetElem.prop('offsetWidth');
476476
var targetHeight = angular.isDefined(targetElem.offsetHeight) ? targetElem.offsetHeight : targetElem.prop('offsetHeight');
477477

478-
if (includeMargins) {
479-
var styles = window.getComputedStyle(targetElem);
480-
var verticalMargin = this.parseStyle(styles.marginTop) + this.parseStyle(styles.marginBottom);
481-
var horisontalMargin = this.parseStyle(styles.marginLeft) + this.parseStyle(styles.marginRight);
478+
// if (includeMargins) {
479+
// var styles = window.getComputedStyle(targetElem);
480+
// var verticalMargin = this.parseStyle(styles.marginTop) + this.parseStyle(styles.marginBottom);
481+
// var horisontalMargin = this.parseStyle(styles.marginLeft) + this.parseStyle(styles.marginRight);
482482

483-
targetHeight += verticalMargin;
484-
targetWidth += horisontalMargin;
485-
}
483+
// targetHeight += verticalMargin;
484+
// targetWidth += horisontalMargin;
485+
// }
486486

487487
placement = this.parsePlacement(placement);
488488

489489
var hostElemPos = appendTo
490490
? appendToBody
491-
? this.offset(hostElem, includeMargins, null)
492-
: this.offset(hostElem, includeMargins, appendTo)
491+
? this.offset(hostElem, false, null)
492+
: this.offset(hostElem, false, appendTo)
493493
: this.position(hostElem, false);
494494
var targetElemPos = {top: 0, left: 0, placement: ''};
495495

@@ -573,6 +573,14 @@ angular.module('ui.bootstrap.position', [])
573573

574574
targetElemPos.top = Math.round(targetElemPos.top);
575575
targetElemPos.left = Math.round(targetElemPos.left);
576+
/* remove half pixel for centering on even-pixel element width/height */
577+
if (hostElemPos.height % 2 === 0) {
578+
targetElemPos.top -= 0.5;
579+
}
580+
if (hostElemPos.width % 2 === 0) {
581+
targetElemPos.left -= 0.5;
582+
}
583+
576584
targetElemPos.placement = placement[1] === 'center' ? placement[0] : placement[0] + '-' + placement[1];
577585

578586
return targetElemPos;

0 commit comments

Comments
 (0)