@@ -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 ;
0 commit comments