Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(tooltip): fix placement issues
Browse files Browse the repository at this point in the history
Closes #115
  • Loading branch information
pkozlowski-opensource committed Feb 14, 2013
1 parent ff5d119 commit a2bbf4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module( 'ui.bootstrap.popover', [] )
templateUrl: 'template/popover/popover.html'
};
})
.directive( 'popover', [ '$compile', '$timeout', '$parse', function ( $compile, $timeout, $parse ) {
.directive( 'popover', [ '$compile', '$timeout', '$parse', '$window', function ( $compile, $timeout, $parse, $window ) {

var template =
'<popover-popup '+
Expand Down Expand Up @@ -52,15 +52,15 @@ angular.module( 'ui.bootstrap.popover', [] )

// Calculate the current position and size of the directive element.
function getPosition() {
var boundingClientRect = element[0].getBoundingClientRect();
return {
width: element.prop( 'offsetWidth' ),
height: element.prop( 'offsetHeight' ),
top: element.prop( 'offsetTop' ),
left: element.prop( 'offsetLeft' )
top: boundingClientRect.top + $window.pageYOffset,
left: boundingClientRect.left + $window.pageXOffset
};
}

// Show the popover popup element.

function show() {
var position,
ttWidth,
Expand Down
9 changes: 5 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module( 'ui.bootstrap.tooltip', [] )
templateUrl: 'template/tooltip/tooltip-popup.html'
};
})
.directive( 'tooltip', [ '$compile', '$timeout', '$parse', function ( $compile, $timeout, $parse ) {
.directive( 'tooltip', [ '$compile', '$timeout', '$parse', '$window', function ( $compile, $timeout, $parse, $window) {

var template =
'<tooltip-popup '+
Expand Down Expand Up @@ -47,11 +47,12 @@ angular.module( 'ui.bootstrap.tooltip', [] )

// Calculate the current position and size of the directive element.
function getPosition() {
var boundingClientRect = element[0].getBoundingClientRect();
return {
width: element.prop( 'offsetWidth' ),
height: element.prop( 'offsetHeight' ),
top: element.prop( 'offsetTop' ),

This comment has been minimized.

Copy link
@facultymatt

facultymatt Mar 17, 2013

This change breaks tooltips when they appear in modals. Reverting to top: element.prop( 'offsetTop' ), left: element.prop( 'offsetLeft' ) fixes the issue.

left: element.prop( 'offsetLeft' )
top: boundingClientRect.top + $window.pageYOffset,
left: boundingClientRect.left + $window.pageXOffset
};
}

Expand Down Expand Up @@ -82,7 +83,7 @@ angular.module( 'ui.bootstrap.tooltip', [] )

// Get the position of the directive element.
position = getPosition();

// Get the height and width of the tooltip so we can center it.
ttWidth = tooltip.prop( 'offsetWidth' );
ttHeight = tooltip.prop( 'offsetHeight' );
Expand Down

0 comments on commit a2bbf4d

Please sign in to comment.